I am using python under VS. When running the following code
import librosa
from IPython.display import Audio
sr = 22050
y_sweep = librosa.chirp(fmin=librosa.note_to_hz('C3'),
fmax=librosa.note_to_hz('C5'),
sr=sr,
duration=5)
Audio(data=y_sweep, rate=sr)`
I CAN NOT hear any sound. The windows speakers are OK Volume is set loud. and the default player is Windows media player (works OK). I don't get any error message. On another similar code when using the
img = librosa.display.specshow
(.... it works OK, but again with no actual sound.)
I was expecting to hear. The code is taken from .html#sphx-glr-auto-examples-plot-audio-playback-py. When using the play button on the above site, sound is correctly heard.
I am using python under VS. When running the following code
import librosa
from IPython.display import Audio
sr = 22050
y_sweep = librosa.chirp(fmin=librosa.note_to_hz('C3'),
fmax=librosa.note_to_hz('C5'),
sr=sr,
duration=5)
Audio(data=y_sweep, rate=sr)`
I CAN NOT hear any sound. The windows speakers are OK Volume is set loud. and the default player is Windows media player (works OK). I don't get any error message. On another similar code when using the
img = librosa.display.specshow
(.... it works OK, but again with no actual sound.)
I was expecting to hear. The code is taken from https://librosa./doc/main/auto_examples/plot_audio_playback.html#sphx-glr-auto-examples-plot-audio-playback-py. When using the play button on the above site, sound is correctly heard.
Share Improve this question asked Mar 31 at 17:33 Jacob SternJacob Stern 1 New contributor Jacob Stern is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 0IPython audio playback works only in Jupyter Notebooks. If you run standard Python, you need some other solution for playing audio. sounddevice is suitable for you, it can play audio from a numpy array
Install via pip:
$ pip install sounddevice
Then replace IPython Audio(...)
with sounddevice audio playing:
import librosa
import sounddevice
sr = 22050
y_sweep = librosa.chirp(
fmin=librosa.note_to_hz("C3"), fmax=librosa.note_to_hz("C5"), sr=sr, duration=5
)
sounddevice.play(data=y_sweep, samplerate=sr)
sounddevice.wait() # don't fet to wait for audio playback to complete