I am having trouble creating a mel-spectrogram in librosa using a custom file path to my sound.
I am following this documentation: https://librosa.github.io/librosa/generated/librosa.feature.melspectrogram.html
And I have looked at this stack overflow post: Spectrograms generated using Librosa don't look consistent with Kaldi?
However none of this helped me solve my issue.
import librosa
y, sr = librosa.load("path_to_my_wav_file")
librosa.feature.melspectrogram(y=y, sr=sr)
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 4))
librosa.display.specshow(librosa.power_to_db(y,
ref=np.max), y_axis='mel', fmax=8000, x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('Mel spectrogram')
plt.tight_layout()
Can someone tell me how to fix this code so that it properly displays and saves the mel-spectrogram to jpg file? Thanks!
oh, Your question is mainly about how to save it as jpg? If you just want to display pictures,You just need to add a line of code:
plt.show()
if you want save a jpg, no axis, no white edge: