我正在尝试实现一个使用Mel频率倒谱系数(MFCC)和动态时间规整(DTW)的语音识别模块。
我将信号(x(N))分成25ms的帧,重叠10ms,并找到每个帧的MFCC参数。我的主要疑问是在这种情况下如何执行DTW。假设有M个帧,N(13)个MFCC系数。
所以我有一个M x N矩阵。
发布于 2017-02-26 07:09:57
MxN的矩阵可以表示为一维向量MxN长度。
所以,你有pattern1
p1[M*N], len=i, 'silence-HHHEEEEELLLLLOOOOOOOO-silence' sound;然后,第二个
p2[M*N], len=j, like 'HHHHHHEEELLOOOO'然后DTW通过曼哈顿、欧几里得、Bray-Curtis等距离计算,得到输出的2维矩阵,就会有一条权值最小的路径。
发布于 2019-07-09 17:41:39
DTW的使用假设在您的案例中验证两个音频序列。因此,对于要验证的序列和查询M2xN,您将拥有一个矩阵M1xN。这意味着您的成本矩阵将具有M1xM2。
要构建成本矩阵,您必须在序列之间应用距离/成本度量,如成本(i,j) = your_chosen_multidimension_metric(M1i,:,M2j,:)
得到的成本矩阵将是2D的,您可以很容易地应用DTW。
我基于MFCC为DTW编写了类似的代码。下面是Python实现,其中returs score;x和y是语音序列的MFCC矩阵,具有M1xN和M2xN维度:
def my_dtw (x, y):
cost_matrix = cdist(x, y,metric='seuclidean')
m,n = np.shape(cost_matrix)
for i in range(m):
for j in range(n):
if ((i==0) & (j==0)):
cost_matrix[i,j] = cost_matrix[i,j]
elif (i==0):
cost_matrix[i,j] = cost_matrix[i,j] + cost_matrix[i,j-1]
elif (j==0):
cost_matrix[i,j] = cost_matrix[i,j] + cost_matrix[i-1,j]
else:
min_local_dist = cost_matrix[i-1,j]
if min_local_dist > cost_matrix[i,j-1]:
min_local_dist = cost_matrix[i,j-1]
if min_local_dist > cost_matrix[i-1,j-1]:
min_local_dist = cost_matrix[i-1,j-1]
cost_matrix[i,j] = cost_matrix[i,j] + min_local_dist
return cost_matrix[m-1,n-1]https://stackoverflow.com/questions/42314430
复制相似问题