如何在MFCC系数数组上执行DTW?

时间:2016-09-28 16:01:47

标签: arrays matlab speech-recognition voice-recognition mfcc

目前我正在MATLAB中从事语音识别项目。  我已经拍摄了两个语音信号,并提取了相同的MFCC系数。 据我所知,我现在应该计算两者之间的欧几里德距离,然后应用DTW算法。这就是为什么我计算了两者之间的距离并获得了一系列距离。 所以我的问题是如何在结果数组上实现DTW?

这是我的MATLAB代码:

全部清除;关闭所有; CLC;

% Define variables
Tw = 25;                % analysis frame duration (ms)
Ts = 10;                % analysis frame shift (ms)
alpha = 0.97;           % preemphasis coefficient
M = 20;                 % number of filterbank channels 
C = 12;                 % number of cepstral coefficients
L = 22;                 % cepstral sine lifter parameter
LF = 300;               % lower frequency limit (Hz)
HF = 3700;              % upper frequency limit (Hz)
wav_file = 'Play.wav';  % input audio filename
wav_file1 = 'Next.wav';


% Read speech samples, sampling rate and precision from file
[ speech, fs, nbits ] = wavread( wav_file );
[ speech1, fs, nbits ] = wavread( wav_file1 );

% Feature extraction (feature vectors as columns)
[ MFCCs, FBEs, frames ] = ...
                mfcc( speech, fs, Tw, Ts, alpha, @hamming, [LF HF], M, C+1, L );
[ MFCC1s, FBEs, frames ] = ...
                mfcc( speech1, fs, Tw, Ts, alpha, @hamming, [LF HF], M, C+1, L );

L = pdist2(MFCCs, MFCC1s, 'euclidean');

2 个答案:

答案 0 :(得分:0)

免责声明:我不是matlab用户。

我认为你的陈述中可能存在误解“我现在应该计算两者之间的欧几里德距离然后应用DTW算法”。

使用DTW的重点是你必须比较两个系列(wav 1和wav 2的MFCC系列),并且两个wav的持续时间可能不同,所以你最终会得到两组MFCC不同大小的矢量。 DTW可帮助您比较两个MFCC系列,无论其大小如何(请参阅https://en.wikipedia.org/wiki/Dynamic_time_warping)。

因此,例如,如果你已经提取了3个MFCC特征向量用于wav 1,5个MFCC特征向量用于wav 2,通过应用DTW你可以比较它们,从而有效地获得它们之间的差异或距离。你不必在DTW之前计算距离,你使用DTW来计算它(事实上,我不知道如何计算不同长度系列之间的距离)。

就像我在开始时所说的那样,我不是一个matlab用户,但是对“matlab dtw”的快速谷歌搜索向我指出了这篇文章:https://www.mathworks.com/help/signal/ref/dtw.html,其中他们引用了dtw()

  dist = dtw(x,y) stretches two vectors, x and y, onto a common set of
  instants such that dist, the sum of the Euclidean distances between
  corresponding points, is smallest

答案 1 :(得分:0)

我建议使用标准欧几里得距离而不是欧几里得距离,因为MFCC系数在每个维度上都有不同的范围。

例如,如果您具有以下2维向量A(500,4),B(504,4)和C(502,3),则使用欧几里得距离将得出dist(A,C)dist(A ,B),因为每个尺寸距离均以其均值标准化。因此,您将(504-500)/ 502 <(4-3)/3.5

因此,对于MFCC,最好使用此标准化步骤来改善结果。