如何解决此Typeerror?

时间:2018-08-08 07:46:30

标签: python tensorflow

使用TensorFlow后端,我遇到此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 个答案:

答案 0 :(得分:0)

通常来说,当您尝试将Array传递给函数时,会收到错误消息“只能将length-1数组转换为Python标量”,该函数需要单个值。

如果要应用在数组中的每个项目上接受单个值的函数,则可以使用np.vectorize

Win 似乎就是那个数组,所以 Win astype(int)是正确的转换。