Audio Clustering Based on Spectral Features
Use spectral features to find clusters in a list of audio objects.
In[1]:=
a = ExampleData[{"Audio", "Drums"}, "Audio"]
Split the recording where transients happen.
In[2]:=
samples =
Select[AudioSplit[a,
FindPeaks[AudioLocalMeasurements[a, "Novelty"]]["Times"]],
Duration@# > Quantity[50, "ms"] &];
samples = Audio[#, Appearance -> "Minimal"] & /@ samples
Out[2]=
Plot the resulting samples in positions defined by their spectral centroid and spectral spread.
In[3]:=
ListPlot[Partition[
AudioMeasurements[#, {"SpectralCentroid", "SpectralSpread"},
"List"] & /@ samples, 1],
PlotMarkers -> (Audio[#, Appearance -> "Minimal"] & /@ samples),
AxesLabel -> {Style["Centroid", Italic], Style["Spread", Italic]},
ImageSize -> Medium]
Out[3]=
Find similar sounds using the "SpectralCentroid" and "SpectralSpread" measurements.
In[4]:=
FindClusters[
AudioMeasurements[#, {"SpectralCentroid", "SpectralSpread"},
"List"] & /@ samples -> samples]
Out[4]=