tyiannak / pyAudioAnalysis

Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications
Apache License 2.0
5.83k stars 1.19k forks source link

Not sure whether it's a bug on mfccInitFilterBanks #196

Open alvations opened 6 years ago

alvations commented 6 years ago

At https://github.com/tyiannak/pyAudioAnalysis/blob/master/pyAudioAnalysis/audioFeatureExtraction.py#L169, there's a check on the sampling frequency fs < 8000 and then the number of logistic filters is reduced to 5:

def mfccInitFilterBanks(fs, nfft):
    """
    Computes the triangular filterbank for MFCC computation 
    (used in the stFeatureExtraction function before the stMFCC function call)
    This function is taken from the scikits.talkbox library (MIT Licence):
    https://pypi.python.org/pypi/scikits.talkbox
    """

    # filter bank params:
    lowfreq = 133.33
    linsc = 200/3.
    logsc = 1.0711703
    numLinFiltTotal = 13
    numLogFilt = 27

    if fs < 8000:
        nlogfil = 5

But it looks like the nlogfil is never used. Is it supposed to be:

    if fs < 8000:
        numLogFilt = 5

BTW, what does linsc and logsc mean?

nss350 commented 5 years ago

I have audio files sampled at 4096Hz and was receiving index out of bounds errors from this method when doing feature extraction. Doing the change you suggested fixed that for me.

This appears to be the same issue as ticket #202
The person who wrote that ticket said 16KHz files were working fine which seems logical given what the if statement is checking for.