5
$\begingroup$

Ok, so I'm trying to compare two different speech signals and I have come into a problem. Here goes:

I have split the signal into blocks, and I have computed the MFCC coefficients of each block. I then use a DTW algorithm to compare the (inputted) signal to the training signal.

Here is the data:

The training data is the MFCC values of a signal of someone saying "No". If I have the inputted signal of someone saying no the values then give:

13.9462, 55.8784, 38.3383, 29.9468, 32.7136, 24.8893, 34.0734, 24.3645, 39.329, 20.4847, 31.1939, 29.8841, 25.7655, 28.222, 23.1643, 33.4366, ....., ......

Where the max data for this dataset is: 97.4834

Here is the data for someone saying a different word:

28.6696, 65.8777, 44.2725, 31.6083, 42.6541, 38.4104, 26.6311, 34.9188, 37.2065, 25.2479, 41.5969, 54.2681, 37.0685, 26.2073, 33.9836, 38.7847, 28.3622, 67.8788, 74.9075, ....., ..... Where the max value in this dataset is: 97.5609

My guess (reading through the algorithm) is that the smallest difference should be the correct result. However, I do not know if it is possible to either:

1) Calculate the MAX value for each dataset and then see which value is smaller

2) Get the first variable and compare it.

Does anyone have any suggestions to how I would compare these kind of values?

Thank you

$\endgroup$
1
  • $\begingroup$ this is a very old one, but I'm asking myself a related question (dsp.stackexchange.com/questions/38830/…). Have you come up with an answer yourself for this? Maybe post it answering your own question? Thanks! $\endgroup$ Commented Mar 31, 2017 at 14:31

2 Answers 2

1
$\begingroup$

The result of DTW is a matrix $N\times M$, where $N$ is the size of the first MFCC-dataset in comparison and $M$ is the size of the second one. Now to make a decision of how close two datasets are to each other you need to see at the normalized bottom-right value value of the DTW matrix. If it's less than some pre-defined threshold, then you can say that two datasets are of a similar nature. In order to compute the threshold you need to run DTW multiple times and plot a ROC curve. The following sample DTW implementation in Matlab should help:

function cost = dtw (A, B)
  [rowsA colsA] = size (A);
  [rowsB colsB] = size (B);

  D = inf (rowsA + 1, rowsB + 1);
  D(1) = 0;

  for i = 2:rowsA + 1
    for j = 2:rowsB + 1
      d = norm ( A(i - 1, :) - B(j - 1, :) );
      D(i, j) = d + min ([ D(i - 1, j - 1) D(i - 1, j) D(i, j - 1) ]);
    endfor
  endfor

  cost = D(end) / (rowsA + rowsB);
endfunction
$\endgroup$
1
$\begingroup$

First of all, divide the signal in multiple frames. I recommend to use an overlap of 50%. Compute the MFCCs for each frame, then you will obtain a vector of MFCCs for each frame. Finally you will have a matrix of [No of MFFCs, Number of frames], for each signal To compare the similarity between sequences with different time length, compute the Euclidean distance between the two matrices. Also you can use the standardized Euclidean distance (check scipy.spatial.distance.cdist for Python).

cost_matrix = cdist(x, y, metric='euclidean')

Thus, you will obtain a cost matrix. Applying the DTW algorithm on this cost matrix, you will find the score which will tell you the similarity between the input signals. I recommend you to see how a different number of MFCCs affects the results and also take in consideration the length of the signals.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.