Use DTW to Compare Recordings
Import, trim, and preprocess four recordings of the first sentence of Alice in Wonderland.
show complete Wolfram Language input
Copy to clipboard.
In[2]:=
✖
alice = ConformAudio[
MapThread[
AudioNormalize[
AudioChannelMix[AudioTrim[AudioResample[Import[#1], 11025], #2],
1]] &, {urls, times}]]
Out[2]=
Show the plots for the signals.
Copy to clipboard.
In[3]:=
✖
AudioPlot[alice, ImageSize -> Medium]
Out[3]=
Compute and plot the MFCC features for the samples.
Copy to clipboard.
In[4]:=
✖
mfcc = AudioLocalMeasurements[#, "MFCC",
PartitionGranularity -> {.05, .01}]["Values"] & /@ alice;
Copy to clipboard.
In[5]:=
✖
Column[MatrixPlot[#, PlotTheme -> "Minimal", ImageSize -> Medium] & /@
Transpose /@ mfcc]
Out[5]=
Compute the dynamic time warping distance between the recordings using WarpingDistance.
Copy to clipboard.
In[6]:=
✖
DistanceMatrix[mfcc,
DistanceFunction -> WarpingDistance] // MatrixPlot
Out[6]=
Compute the dynamic time warping correspondence between two of the recordings using WarpingCorrespondence.
Copy to clipboard.
In[7]:=
✖
{n, m} = WarpingCorrespondence[mfcc[[1]], mfcc[[2]]];
show complete Wolfram Language input
Out[8]=