I am trying to plot a spectrogram using custom width and height but when I run the followding code it throws me the following error, but when i remove the custom width and height it works fine but it creates the spectrogram in a 515x389
Code:
filename = path
x, sr = librosa.load(filename, mono=True)
widthHeight = (432, 288)
plt.figure(figsize=widthHeight)
plt.specgram(x, NFFT=2048, Fs=2, Fc=0, noverlap=128, cmap='inferno', sides='default', mode='default', scale='dB')
plt.axis('off')
plt.savefig("spec.png", bbox_inches='tight', transparent=True)
plt.clf()
Error
_tkinter.TclError: not enough free memory for image buffer