Dynamic Time Warp through SPTK tool

I'm an IT student and got an assignment to do about Dynamic Time Warping(DTW) using the Speech Signal Processing Toolkit (SPTK) and comparing some words spoken by 2 speakers and finding the similarities. I managed to get the SPTK working, collected 8 people(4 females, 4 males) who recorded 8 words each for me(same words for every person) and saved them as files with a .wav extension.

My .wav files are in the following format:

• RIFF (little-endian) data ;
• WAVE audio ;
• mono ;
• sampled at $16\text{ kHz}$.

I transfered every .wav file into .raw data files with the SPTK conversion function :

wav2raw +f source_maleA.wav


The .raw file I get is:

• Unsigned 8 bit ;
• Sampled at $8 \text{ kHz}$ ;
• Mono.

I transfered every .raw file to a .mcep file with this line of code:

x2x +Sf < source_maleA.raw | frame -l 320 -p 160 -n | window -l 320 -L 512 -n 1 | mcep -l 512 -m 13 -a 0.42 > source_maleA.mcep


After that, I went to compare the .mcep files with this line of code:

dtw -m 13 -s Scorefile target_maleB.mcep < source_maleA.mcep > source_maleA_target_maleB.dtw


The output of that command line (the "Scorefile") is a binary file.

I programmed a code that decodes the binary sequence written inside of the Scorefile and the output is some kind of decimal number: $0.678382$, which could imply a percentage of something.

Since by the SPTK documentation they are using some .short files of their own, I tried to remove the header of the .wav files and use them as .raw format and then convert it to .mcep file for the further use.

Since my understanding of DTW is limited by itself, plus my understanding of the SPTK tool is also limited, could anyone tell me if what I did is good?

I divided the files into frames of $320$ samples and periods of 160 and I used $x[0]$ as the first point of the first frame. I applied a Blackman's window of 512 samples length with the normalization computed by this function:

$$\sum_{n=0}^{L-1} w^2 (n) = 1$$

After that I used the mel cepstral analysis to get the coefficients with $alpha = 0.42$ and I set the mc order to $13$.

Since when changing the length of the window, frames, period etc. etc. I don't get any better result, could anyone explain me what would be a good setup for all those factors?

Link to the SPTK (for the documentation and examples)

• you say "I programmed a code that decodes the binary sequence written inside of the Scorefile". What decoding did you use? Just natural binary decoding? Also I didn't quite get the cepstral analysis part. Where does it come, after or before the DTW? – Florent Sep 7 '17 at 23:37
• Natural binary decoding yeah. I actually applied the cepstral analysis through the mcep command. It comes before the dtw. – MarcoBubi Sep 8 '17 at 3:17

The documentation clearly says (emphasis mine):

If –s option is specified, the score calculated by dynamic time warping, that is, the distance between the test data and the reference data is output and sent to Scorefile.

That means that your decimal number, $0.678382$, is the actual DTW distance between your 2 speech samples.

Now DTW is a distance measurement, and as any distance it only gives you relative information. For example, you could set a treshold and says that under this treshold, the 2 signals correspond to the same word. If you apply DTW on a pitch contour, you could determine whether the 2 melodies are similar (that's used in query by humming).

Of course, the physical meaning of the distance depends completely on the one of the time series compared : if you compare voltage values, or frequency values, etc. In your case, you compare normalized volumes mapped to unsigned 8-bit data.

I advise you to learn more about DTW and to try to analyse what the distance actually tells you, and how that relates to your application

• The thing is that when I compare 2 files that are kind of related(like same word or same speaker) the result is 0.678382 and in some cases when i compare two different speakers saying different stuff(with different accents) the result is not that different and since with most of the stuff in the documentation I had a hard time to get by(some were working fine, some were not and some were not working at all) I was wondering what the results were. I expected some numbers as results, but not so small. – MarcoBubi Sep 8 '17 at 3:24