emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
942 stars 92 forks source link

FeatureRequest: Support audio/video mime types. #413

Open hwiorn opened 2 years ago

hwiorn commented 2 years ago

Currently, emacs-jupyter display audio/video object itself.

#+begin_src jupyter-python :session tqdm :async yes
import IPython.display as ipd
import numpy

sr = 22050 # sample rate
T = 0.5    # seconds
t = numpy.linspace(0, T, int(T*sr), endpoint=False) # time variable
x = 0.5*numpy.sin(2*numpy.pi*440*t)              # pure sine wave at 440 Hz
ipd.Audio(x, rate=sr) # load a NumPy array
#+end_src

#+RESULTS:
: <IPython.lib.display.Audio object>

#+begin_src jupyter-python :session tqdm :async yes
from IPython.display import Audio
Audio('/home/gglee/KsponSpeech_E00001.wav')
#+end_src

#+RESULTS:
: <IPython.lib.display.Audio object>

#+begin_src jupyter-python :session tqdm :async yes
from IPython.display import Video
Video('/home/gglee/Downloads/sample.mp4')
#+end_src

#+RESULTS:
: <IPython.core.display.Video object>

I think emacs-jupyter can display as file link like image type. If so, user can open it using MPV or VLC. Can this be possible?

#+begin_src jupyter-python :session tqdm :async yes
import IPython.display as ipd
import numpy

sr = 22050 # sample rate
T = 0.5    # seconds
t = numpy.linspace(0, T, int(T*sr), endpoint=False) # time variable
x = 0.5*numpy.sin(2*numpy.pi*440*t)              # pure sine wave at 440 Hz
ipd.Audio(x, rate=sr) # load a NumPy array
#+end_src

#+RESULTS:
file:./ob-jupyter/c489bd32e1d94e4fb0504bd561772cb1.wav

#+begin_src jupyter-python :session tqdm :async yes
from IPython.display import Audio
Audio('/home/gglee/KsponSpeech_E00001.wav')
#+end_src

#+RESULTS:
file:./ob-jupyter/471d3914a9ca4a9abe99eea515c23c9e.mp4
TurbulenceChaos commented 1 year ago

I use jupyter-manim package to create animations in org files and export html to see the videos. I also want emacs-jupyter can support "video html" mime types.