Python TypeError

keras
tensorflow

#1

Using TensorFlow backend.

Writing berlin data set to file...
Traceback (most recent call last):
  File "/home/lwin/speech-emotion/Speech_emotion_recognition_BLSTM-master/find_best_model.py", line 163, in <module>
    functions.feature_extract(ds.data, nb_samples=len(ds.targets), dataset=dataset)
  File "/home/lwin/speech-emotion/Speech_emotion_recognition_BLSTM-master/utility/functions.py", line 20, in feature_extract
    hr_pitch = audioFeatureExtraction.stFeatureSpeed(x, Fs, globalvars.frame_size * Fs, globalvars.step * Fs)
  File "/usr/local/lib/python3.5/dist-packages/pyAudioAnalysis/audioFeatureExtraction.py", line 669, in stFeatureSpeed
    [fbank, freqs] = mfccInitFilterBanks(Fs, nfft, lowfreq, linsc, logsc, nlinfil, nlogfil)
TypeError: mfccInitFilterBanks() takes 2 positional arguments but 7 were given

What method is there to solve the problem?


How to solve the problem?
#2

The way you've presented your problem right now makes it impossible to say anything conclusive about the reason for your problem. Can you put your question into reprex? There is more info here:


#3

As with most languages, reading Python's error messages is a skill that needs to be practiced. Also like with other languages, it's a skill worth learning.

The error messages should be read like this:

  • The last line states what type of error occurred (TypeError in this case) and gives a (hopefully) descriptive message. In your case, there were too many arguments given to the mfccInitFilterBanks function.
  • Jumping up to where the error message starts (Traceback...), we read down to see the chain of what's being done from highest level (the statement in your code) to lowest level (the function's definition in the package)
  • We look for where mfccInitFilterBanks was called, which is the lowest level: in the package code of pyAudioAnalysis, line 669 of the audioFeatureExtraction.py file (here's the GitHub version).

In that package file, mfccInitFilterBanks is defined like this:

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
    """

However, that same file later calls the function like this:

[fbank, freqs] = mfccInitFilterBanks(Fs, nfft, lowfreq, linsc, logsc, nlinfil, nlogfil)

So the problem's with the pyAudioAnalysis package. You should create an issue on its GitHub page.