How to play audio in Jupyter notebook with VSCode?

Viewed 561

Using a jupyter notebook in VSCode, I'm trying to run the following code from this documentation:

import numpy as np
from IPython.display import Audio
framerate = 44100
t = np.linspace(0,5,framerate*5)
data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t)
Audio(data, rate=framerate)

However, I only get this

enter image description here

If I press play button, then nothing happens...

1 Answers

As of today, it seems VSCode Jupyter extension does not support audio. You can track the issue here on their Github.

One solution can be merging this pull request and rebuilding VSCode, which is not suggested.

The preferred alternate solution is using jupyter lab instead of VSCode for such use cases.

Related