计算 2 个语音样本的 dtw 时获取错误"dtw() got an unexpected keyword argument 'dist'"



我得到错误"dtw((获得了一个意外的关键字参数"dist"当我试图计算2个wav文件的dtw时。我不知道为什么或该怎么做来修复它。我在下面附上代码。

import librosa
import librosa.display
y1, sr1 = librosa.load('sample_data/Abir_Arshad_22.wav')
y2, sr2 = librosa.load('sample_data/Abir_Arshad_22.wav')
%pylab inline
subplot(1, 2, 1)
mfcc1 = librosa.feature.mfcc(y1, sr1)
librosa.display.specshow(mfcc1)
subplot(1, 2, 2)
mfcc2 = librosa.feature.mfcc(y2, sr2)
librosa.display.specshow(mfcc2)
from dtw import dtw
from numpy.linalg import norm
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)

错误发生在倒数第二行。

错误消息是直接的。让我们阅读您正在调用的方法的文档:

https://dynamictimewarping.github.io/py-api/html/api/dtw.dtw.html#dtw.dtw

dtw功能具有以下参数:

参数x–查询向量或本地成本矩阵

y–参考向量,如果x作为成本矩阵,则未使用

dist_method–要使用的逐点(局部(距离函数。

step_pattern–描述局部扭曲步骤的stepPattern对象允许其成本(参见[stepPattern((](

window_type–窗口函数。字符:"none","itakura","sakocchiba"、"slantedband"或函数(请参阅详细信息(。

open_begin,open_end–执行开放式比对

keep_internals–保留累积成本矩阵、输入和其他内部结构

distance only–仅计算距离(无回溯,更快(

您试图传递一个名为dist的参数,但该参数根本未知。

相反,消除这种争论可以解决问题,比如

dist, cost, acc_cost, path = dtw(mfcc1.T, mfcc2.T)

相关内容

最新更新