1

I am extracting Mel spectrogram from the audio file then I want to apply padding

y,sr = librosa.load(r"/content/test.WAV")
mel = librosa.feature.melspectrogram(y=y, sr=sr)
mel=np.mean(mel, axis=0)
mel=tf.keras.preprocessing.sequence.pad_sequences(mel,maxlen=1500)

but I am receiving TypeError: object of type 'numpy.float32' has no len()During handling of the above exception, another exception occurred:
ValueError: sequences must be a list of iterables. Found non-iterable: 0.0382184 I tried changing mel=tf.keras.preprocessing.sequence.pad_sequences(list(mel),maxlen=1500) and it didn't work there are 2 or 3 questions on StackOverflow similar to my questions none of them helped me so please don't bother to suggest them

Mohamed Amine
  • 340
  • 1
  • 4
  • 16
  • no, the mel=np.mean(Mel, axis=0)doesn't return a single float it returns a NumPy array of shape (4280,) – Mohamed Amine May 23 '21 at 19:03
  • Read the error message, it says that sequences must be a list of iterables, a numpy array (4280,) is not a list of iterables, a 2D list would be. – Dr. Snoopy May 23 '21 at 20:08
  • so what is the solution I am using this for inference so I can only provide 1 list when I used the padding for 1300 list in training it worked – Mohamed Amine May 23 '21 at 20:13

1 Answers1

1

I just figured it out you have to do some reshaping

mel=mel.reshape(1,mel.shape[0])
Mohamed Amine
  • 340
  • 1
  • 4
  • 16