python-3.x - 如何在 Python 3 中比较和可视化两个 .wav 文件?
问题描述
我在 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 ,如果你使用的是 python 的 anaconda 发行版,那么在 anaconda 提示符下运行pip install librosa
或者运行你的 CMD 。
其次import librosa
在 jupyter 上然后开始工作。
推荐阅读
- asp.net-core - asp.net core 3.1中的区域端点路由
- powerquery - 将 PowerQuery 中的空列表修复为 RESTFUL API
- ios - iOS Metal 可以有条件地将命令编码到命令缓冲区
- reactjs - 反应本机传奇产量调用不起作用
- stylus - 如何使手写笔包含导入的 CSS 的内容而不是生成 CSS 导入语句?
- python - 简单的 TF2 Keras 模型预测速度要慢得多,并且似乎无法在启用急切执行的情况下进行训练
- symfony - 我无法使用 Composer 安装特定版本的 Symfony
- ios - 使用同一帐户的分发证书和配置文件重新签署开发 IPA 时是否需要 entitlement.plist 文件?
- java - 在 Java 中手动编写折线图的最佳方法是什么
- react-native - 移动应用程序的启动画面部署到多个客户并且每个客户都是唯一的