I try to save the generated spectrogram images in my drive But I am not able to save the exact spectrogram images.
from pathlib import Path
base_path = Path('/content/drive/MyDrive/Audio')
for wav_file_path in base_path.glob("*.wav"):
print(f"WAV File: {wav_file_path}")
x,sr=librosa.load(wav_file_path)
mel_spectrogram=librosa.feature.melspectrogram(y=x,sr=sr)
plt.figure(figsize=(10,4))
plt.grid(True)
fig = plt.Figure(figsize=(10,4))
librosa.display.specshow(librosa.power_to_db(mel_spectrogram, ref=np.max))
fig.savefig('/content/drive/MyDrive/Spec/spec.png')
But, it saves the image which is shown in below format instead of spectrogram images.