-4

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
Anil_M
  • 10,893
  • 6
  • 47
  • 74
thaingiW
  • 1
  • 3
  • Show us the [mcve] that produces this. –  Aug 08 '18 at 07:51
  • 1
    The message you are getting is descriptive, to help you further, you need to include your code. And welcome to SO, please please take your time and read thru this: https://stackoverflow.com/help/how-to-ask – Drahoš Maďar Aug 08 '18 at 07:53
  • This is python code: lowfreq = 133.33 linsc = 200/3. logsc = 1.0711703 nlinfil = 13 nlogfil = 27 Win =Win.astype(int(Win)) Step = int(Step) – thaingiW Aug 08 '18 at 08:16
  • @thaingiW I dont really thing thats your whole code. Update your post with full indented code please – Drahoš Maďar Aug 08 '18 at 08:40

1 Answers1

0

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.

Drahoš Maďar
  • 517
  • 2
  • 6
  • 22