【发布时间】:2019-11-21 09:07:24
【问题描述】:
我在 Jupyter 上使用 Python 3,我试图找出音频文件(有一些噪音)与没有原始文件的准确性。请在下面找到我在网上找到的代码,
import librosa
import matplotlib.pyplot as plt
from dtw import dtw
#Loading audio files
y1, sr1 = librosa.load('data/dev1_female3_liverec_130ms_1m_sim_1.wav')
y2, sr2 = librosa.load('data/dev1_female3_liverec_130ms_1m_sim_1o.wav')
#Showing multiple plots using subplot
plt.subplot(1, 2, 1)
mfcc1 = librosa.feature.mfcc(y1,sr1) #Computing MFCC values
librosa.display.specshow(mfcc1)
plt.subplot(1, 2, 2)
mfcc2 = librosa.feature.mfcc(y2, sr2)
librosa.display.specshow(mfcc2)
dist, cost, path = dtw(mfcc1.T, mfcc2.T)
print("The normalized distance between the two : ",dist) # 0 for similar audios
plt.imshow(cost.T, origin='lower', cmap=plt.get_cmap('gray'), interpolation='nearest')
plt.plot(path[0], path[1], 'w') #creating plot for DTW
plt.show()
我收到一个错误“找不到模块名称 librosa”
【问题讨论】:
-
你安装了 librosa 模块吗?
-
如果不是你需要先安装它
pip install librosa -
我正在使用 Jupyter 笔记本,所以我不确定在哪里写。
-
更新:解决了 librosa 问题
-
更新:安装 librosa 和 dtw 后,出现错误:AttributeError: module 'librosa' has no attribute 'display'
标签: python-3.x audio-comparison