Search code examples
pythonaudiojupyter-notebook

IPython.display doesn't show long wav files


I use IPython.display for listening audio file in Jupyter notebook. I have a long file(30 min).


import IPython.display as dis
import numpy
y = numpy.zeros(30*60*48000)

This code work as fluidly for 5 seconds

dis.display(dis.Audio(y[:5*48000], rate=48000))

but for 30 minutes the code hangs and there are no errors.

dis.display(dis.Audio(y, rate=48000))

Is this method not suitable for displaying long audios and is it limited? Is there another way to display long files?


Solution

  • You can use pydub library:

    from pydub import AudioSegment
    audio = AudioSegment.from_wav("your_audio.wav")
    audio