Referring to this link: https://aqibsaeed.github.io/2016-09-03-urban-sound-classification-part-1/, I am trying to make the same waveplot figure, however,i run the code through .py, there is the error:
(tensorflow) yyydeMacBook-Pro:~ yyy$ python /Users/yyy/Desktop/1.py
Traceback (most recent call last):
File "/Users/yyy/Desktop/1.py", line 82, in <module>
plot_waves(sound_names,raw_sounds)
File "/Users/yyy/Desktop/1.py", line 42, in plot_waves
librosa.display.waveplot(np.array(f),sr=22050)
AttributeError: 'module' object has no attribute 'display'
From this github issue I read that it is now necessary to import librosa.display
.
[Update 2022] Apparently now also waveplot
needs to be changed to waveshow
, like below:
(thanks to Hammad Hassan in comments!)
import librosa.display
plt.figure(figsize=(12, 4))
librosa.display.waveshow(data, sr=sampling_rate)
just import the display
import librosa.display
plt.figure(figsize=(12, 4))
librosa.display.waveplot(data, sr=sampling_rate)
If you are running librosa 0.9.0 you will run into following Error using waveplot:
AttributeError: module 'librosa.display' has no attribute 'waveplot'
instead: import librosa.display and use waveshow
path = "sample.wav"
data, sampling_rate = librosa.load(path)
librosa.display.waveshow(data, sr=sampling_rate)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With