# Two voice pronunciation comparison similarity MFCC + DTW

Calculate each MFCC to compare wave file A and wave file B, and then use FastDTW to measure the distance after two sets of MFCCs.

We compared the four wave files and obtained the Euclidean distance value.

The values below are the Euclidean distance values.

675.0095954620155 A.wav vs. A2.wav

998.7554375714773 A.wav vs B.wav

976.1293903229977 A.wav vs. B2.wav

856.4364672719398 A.wav vs C.wav

645.8353052519245 A.wav vs C2.wav

1. I do not know how the Euclidean distance values look for similarity.
2. Is the similarity rate high when the distance value approaches zero?
3. How do you know there is a high match with this distance value?
4. Is not DTW a library to see how similar the voices are?

4: DTW (Dynamic Time Warping) is not a library but an algorithm. It allows aligning two sequences by warping them in time. You can use it for pretty much any kind of sequential data, for which a metric (distance) can be defined. Generally, you calculate a distance between each and every point of both sequences and produce a big matrix of accumulated distances. In the end, a path that produces the smallest final cost is selected as the optimal.

Here is an example of two 1D signals: $$\color{blue} {x_1}$$ is an exponential sweep sine and $$\color{orange} {x_2}$$ is a sinusoid with a constant frequency. The goal is to warp the $$\color{orange} {x_2}$$ in time so it would match the $$\color{blue} {x_1}$$ as close as possible. The figure below shows the outcome of such alignment. The signal $$\color{orange} {x_2}$$ had been stretched so that it matches $$\color{blue} {x_1}$$. However, $$\color{orange} {x_2}$$ is shorter than $$\color{blue} {x_1}$$, hence it had to be padded towards the end. The subplot at the bottom shows the evolution of the distance for each frame, where the final value is the accumulated cost - the very thing that you are using in your comparison. From this example, you can immediately see some limitations of the DTW.

Just to wrap up, here is the full DTW matrix together with the optimal path.

3 & 2: It's a distance, so the lower the better. The lowest possible distance is $$0$$, which can be achieved when:

• Both signals are exactly the same
• One signal is the stretched version of the other one, such as [0, -1, 0, 1, 0] and [0, -1, 0, 0, 1, 1, 0].

1: As I've mentioned before, DTW compares the distance between each and every point and then accumulates the cost of all operations that lead up to that point - the path that will yield the minimal cost corresponds to the best alignment.

In terms of similarity, signals will be considered close to each other if stretching or squeezing certain parts will minimize the difference between the MFCC vectors for each frame.

These answers might be relevant for you: click, click, click.

• Thank you for your response has been a great help. – 김세중 Oct 11 '18 at 6:27