# Applying DTW on MFCC frames

I want to use MFCC (Mel-frequency cepstral coefficients) and DTW (dynamic time warping) algorithms to make a speech comparison script. I calculated MFCC and got 13 coefficients for each frame.

How do I calculate DWT from that? Should I discard the frames and just look at coefficents as an array. I read in this post: Speech recognition using MFCC and DTW(Dynamic Time Warping)? that you should calculate DTW between each frame, but I don't understand what I should do after I have calculated all those DTWs. If I have one audio sequence of $n$ frames and the other one of $m$ frames, then I get $n \times m$ DTW costs. And, where do I go from there.

• You take the rightmost upper coefficient as a total distance. Or in other words, the distance that you are looking for is at the position between last frames. Usually you don't use remaining coefficients, they are just an intermediate step to obtain the final metric. – jojek Mar 23 '16 at 7:14
• I think the following quote will help you. "In case of DTW you will be calculating the cost between each of 13 dimensional frames (simple distance metric/norm, i.e. Euclidean, Manhattan, etc.)" It is from @jojek's answer here – Hyun Lee Apr 9 '17 at 18:10

Well I think I found a solution to this, mostly by trial and error.

So what I did and its giving quite good results is : 1) If we have M(No. of frames) X N(13;No of MFCC Coefficients) matrix;

ie X=X[1 2 .....N(13) ; 1 2.....M(No of frames) ]

2) Find the DTW of [X(1;1 2 3.....M)] with the DATABASE [REF(1;1 2 3...M)] Here we are taking K=1(Not 2...12) Similarly find DTW of [X(2;1 2 3...M)] and DATABASE [REF(1;1 2 3...M)]

3) On generalizing, Find DTW of [X(k(kth MFCC coef); 1 2 3...m)];

4)So at the end we will get : K(13) values ;

5) Find the mean of these 13(K) values and let that be your Reference for deciding;

*Disclaimer: I am not certain if this is what all the papers imply, I just found it by trial and error and it gives accurate results