1import matplotlib.pyplot as plt
2from scipy import signal
3from scipy.io import wavfile
4
5sample_rate, samples = wavfile.read('path-to-mono-audio-file.wav')
6frequencies, times, spectrogram = signal.spectrogram(samples, sample_rate)
7
8plt.pcolormesh(times, frequencies, spectrogram)
9plt.imshow(spectrogram)
10plt.ylabel('Frequency [Hz]')
11plt.xlabel('Time [sec]')
12plt.show()