Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 607
Ashok Lathwal Avatar asked Mar 31 '18 09:03

Ashok Lathwal


1 Answers

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

like image 105
Abhishek Avatar answered Nov 09 '22 09:11

Abhishek