0
$\begingroup$

I'm working on a audio sample recognition project, where first you profile a sound and then run the sound detection function.

Currently during the 'profile' stage I'm grabbing copies of the magnitude frequency bin from the sound you want to detect (for a changeable pre-set amount of FFTs). During the detection phase I'm trying to use these to compare the similarity of the incoming identical length FFT, to see if they 'match'.

What would be some good methods to compare the two FFTs given that I have a 'learn' phase which can be used. I've tried comparing the maximum frequency bin, which works well to an extent. Voice recognition is easily fooled, with a tone generator (Which makes sense)'.

I'm sampling at 16000Hz with each FFT at 2048 samples long, equating to 128ms of data. Which I believe gives me a frequency range of ~8000hz.

$\endgroup$
  • 1
    $\begingroup$ Tell us more about the content of the audio signals and what kind of variations should be considered a match or a difference. For example: Are two different musical notes played by the same instrument a match? Are the same notes played by a different instrument a match? The same word said by two different person a match? The same sound recorded with two different microphones a match? The raw spectrum is very likely to be the wrong tool. $\endgroup$ – pichenettes Mar 19 '14 at 11:45
  • $\begingroup$ Thanks for the reply. Ideally the program will be able to judge the current environment (In car, outside, inside ect). However the primary goal currently is speaker recognition. All the samples will be recorded from the same microphone. $\endgroup$ – jub Mar 19 '14 at 12:33
  • 1
    $\begingroup$ Speaker recognition as in identifying whether the sentence is spoken by the same person who recorded the "profile"? $\endgroup$ – pichenettes Mar 19 '14 at 12:57
  • $\begingroup$ Exactly, ideally to determine if the speaker matches the voice profile - irrelevant of the words being spoken. $\endgroup$ – jub Mar 19 '14 at 13:09
0
$\begingroup$

FFT won't work because it captures too many details which are rather irrelevant to the task. You need to extract a representation of sound which is more or less invariant by pitch and amplitude changes (properties of sound which are irrelevant to your problem). So you need a "blurred" version of the spectrum - and MFCCs are exactly that.

The textbook-ish, baseline system for speaker verification is to extract MFCCs (first coefficient excluded) on the "profile" recording; train a Gaussian Mixture Model on this data. The more data we have in the profile, the better (ideally, the most common phonemes should all be represented).

To score a new recording (during the "recognition" phase), extract the MFCCs, and compute the likelihood of the model given this data (you'll have to normalize by the length of the recording). Compare the score to a threshold - set according to the false positive rate you want to achieve.

For speaker recognition, you train one model per speaker to recognize; and select the speaker associated with the model with the higher score.

$\endgroup$
  • $\begingroup$ Thank you, very insightful. This looks like exactly what I need. I'm new to DSP. Why is the first coefficient excluded and could this method be applied to recognition outside voices? $\endgroup$ – jub Mar 19 '14 at 13:42
  • $\begingroup$ The first MFCC coefficient represents signal energy. If you do not discard it, your model will "learn" the loudness at which the sentence was spoken; and you might have false negative that are simply due to the "test" sentence pronounced further from the mic or with a lower voice. $\endgroup$ – pichenettes Mar 19 '14 at 14:28
  • $\begingroup$ This could work moderately well for other categories of sound (animal calls, musical instruments...) - up to very rough categorization of genre in music. Keep in mind that it thrashes the temporal structure of the signal and just consider it as a "bag of frames". This won't allow you to recognize a specific sentence, melody, rhythm - just the surface-level "texture" of sound. $\endgroup$ – pichenettes Mar 19 '14 at 14:30
  • $\begingroup$ Good to know. I'm in the process of implementing it now. I'm confused as to how best to 'Map the powers of the spectrum obtained above onto the mel scale, using triangular overlapping windows.'. I have my power spectrum, any tips on how can I use en.wikipedia.org/wiki/Window_function#Triangular_window to map my spectrum to the mel scale, I assume I need to run this once per coefficient? $\endgroup$ – jub Mar 19 '14 at 16:07
  • $\begingroup$ The best way to learn is to look at code from an existing implementation... The frequency remapping is just a weighted sum of FFT magnitudes (or squared magnitudes). $\endgroup$ – pichenettes Mar 19 '14 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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