【发布时间】:2022-07-26 20:58:38
【问题描述】:
首先,我真的不知道我在用这段代码做什么。我只是想比较两个 .wav 文件并检查发音正确性。我搜索了互联网,发现这可以使用 MFCC 和 DWT 来完成。我有一个示例代码,它工作正常。但我想得到两个声音之间的距离百分比。有人可以帮我解决这个问题吗?以及如何读取这个结果,0.0 表示原始文件和测试文件,两者都是一样的。这意味着数字越低越好对吗?
import librosa
from dtw import dtw
from numpy.linalg import norm
y1, sr1 = librosa.load('original.wav')
y2, sr2 = librosa.load('testing_file.wav')
mfcc1 = librosa.feature.mfcc(y1, sr1)
mfcc2 = librosa.feature.mfcc(y2, sr2)
dist, cost, acc_cost, path = dtw(mfcc1.T, mfcc2.T, dist=lambda x, y: norm(x - y, ord=1))
print ('Normalized distance between the two sounds:', dist)
#Normalized distance between the two sounds: 52367.556983947754
【问题讨论】:
标签: python audio similarity mfcc dwt