# DCT step suppress high frequencies in MFCC extraction process

I'm trying to get MFCC from speech audio data. I'm using 26 Mel Filter on 0-24kHz spectrum. My MFCCs doesn't look correct to me, cause always first bins have high values and values getting smaller through the high frequency bins, even with high frequency audio data.

Then I realized that the cos((PI/N)*(n+0.5)*k) part in the DCT Type II formula, causes this result. Here is how the value of that cos() part changes by increasing the number of mel filter bin: http://img402.imageshack.us/img402/5994/dctresult.png

When I multiply the mel filter bank energies with that cos() part, the MFCCs have only low frequencies and high frequencies are getting suppressed. MFCC result of a "s" sound has a frequency of 5khz-10khz: http://img9.imageshack.us/img9/4279/mfccresult.png

Here is my code of DCT(Discrete Cosine Transform) step:

numofMelFilters = 26;
numofMFCCs = 26;    // This ll be 12..
for(int k=0; k<numofMFCC; k++){
for(int n=0; n<numofMelFilters; n++){
MFCC[k] += melEnergies[n] * cos((PI / (double)numofMelFilters) * (n + 0.5) * k);
}
}


I can't find out what I am doing wrong, any help will be appreciated. Thanks in advance..

I think you misinterpret the output coefficients of the DCT. If you want to look at the frequency content of your input signal, you need to look at the output of the triangular filter bank, before the DCT. So if there is a fricative, like an "s" sound, the outputs of the high frequency filter bank kernels will have a higher energy than when the input is a vowel. However, after the DCT you do not have this type of frequency information, because you take the DCT of a frequency-domain signal, not of a time-domain signal. So the "high-frequency" bins of the DCT output correspond to fast variations in the shape of the spectrum, not to high frequencies in the input (time-domain) signal. The very effect you see, is exactly what the DCT is supposed to do. It compresses the input data, in the sense that almost all information is contained in the lower DCT bins. Usually the higher DCT bins are not used, which in fact means that you are doing lossy compression of your data. Luckily it turns out the the information that is being thrown away is actually irrelevant for the performance of the speech recognizer, and neglecting this information makes the recognition even more robust.

Having said that, of course there can still be a bug in your code, but the effect you describe is actually a desired result and nothing to worry about.

• @Neeks , Matt Thank you for your answers. Actually I thought the same thing when I realized the changing of cos() term in the formula. But I have found some MFCC graphs in tutorials, and in those graphs MFCC results looks similar to original spectrum. That made me confused. Here is an example from a tutorial : img541.imageshack.us/img541/6535/mfccgraph.png – rottenclover Jun 10 '13 at 7:24

In case you are using constant energy triangular filters (with BW constant on a mel scale hence increasing with center freq. on a linear scale), then the peak value in the freq. response will decrease with center freq. for the different triangular filters. This weight the response to high frequencies by a smaller amount than the response to low frequencies.