dsp_spectogram.py 365 B

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