How to solve this Typeerror?

76 views Asked by At

Using TensorFlow backend I am getting this Typeerror,

Traceback (most recent call last):
  File "/home/lwin/speech-emotion/Speech_emotion_recognition_BLSTM-master1/prediction.py", line 36, in <module>
    f = functions.feature_extract((y, sr), nb_samples=1, dataset='prediction')
  File "/home/lwin/speech-emotion/Speech_emotion_recognition_BLSTM-master1/utility/functions.py", line 17, in feature_extract
    f = audioFeatureExtraction.stFeatureExtraction(x, Fs, globalvars.frame_size * Fs, globalvars.step * Fs)
  File "/usr/local/lib/python3.5/dist-packages/pyAudioAnalysis/audioFeatureExtraction.py", line 544, in stFeatureExtraction
    Win =Win.astype(int(Win))
TypeError: only length-1 arrays can be converted to Python scalars
1

There are 1 answers

0
Drahoš Maďar On

Generally speaking, you'll get error "only length-1 arrays can be converted to Python scalars" when you are trying to pass an Array to function, which expects single value.

If you want to apply function which accepts single value on each item in Array, you can use np.vectorize

Win seems to be that Array, so Win.astype(int) is correct casting.