librosa.display.waveplot(np.array(f),sr=22050)-----AttributeError: 'module' object has no attribute 'display'

新手上路,请多包涵

参考此链接: https ://aqibsaeed.github.io/2016-09-03-urban-sound-classification-part-1/,我试图制作相同的波形图,但是,我通过运行代码。 py,出现错误:

 (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'

原文由 Yiin 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 744
1 个回答

从这个 github问题 我读到现在有必要 import librosa.display

[更新 2022] 显然现在也 waveplot 需要更改为 waveshow ,如下所示:( 感谢 Hammad Hassan 的评论!)

 import librosa.display
plt.figure(figsize=(12, 4))
librosa.display.waveshow(data, sr=sampling_rate)

原文由 Herman 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题