Ashok Lathwal
Ashok Lathwal

Reputation: 349

ParameterError : data must be floating-point (librosa)

Refernce : https://github.com/librosa/librosa/blob/master/examples/LibROSA%20demo.ipynb

Code :

import librosa

S = librosa.feature.melspectrogram(samples, sr=sample_rate, n_mels=128)

log_S = librosa.power_to_db(S, ref=np.max)
plt.figure(figsize=(12,4))

librosa.display.specshow(log_S, sr=sample_rate, x_axis='time', y_axis='mel')

plt.title('mel power spectrogram')

plt.colorbar(format='%+02.0f dB')

plt.tight_layout()

Erorr I am getting :

Error i am getting

Upvotes: 7

Views: 14975

Answers (1)

Abhishek Raj
Abhishek Raj

Reputation: 488

The parameter -- > samples in below method is not correct.

S = librosa.feature.melspectrogram(samples, sr=sample_rate, n_mels=128)

We are getting samples from wavfile read.

sample_rate, samples = wavfile.read(str(train_audio_path) + filename)

problem is specified in here wave file read wrong

So use the following line of code for getting samples in correct dtype.

samples, sample_rate = librosa.load(str(train_audio_path)+filename)

Reference : librosa.github.io

Upvotes: 13

Related Questions