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 :
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With