from numpy import array, arange, zeros, shape, log10, vstack
from pylab import imshow, show, cm, axis, ylabel, xlabel, xticks, yticks
-def get_spectrogram(filename):
- samplerate = 44100
+def get_spectrogram(filename, samplerate = 0):
win_s = 512 # fft window size
hop_s = win_s / 2 # hop size
fft_s = win_s / 2 + 1 # spectrum bins
a = source(filename, samplerate, hop_s) # source file
+ if samplerate == 0: samplerate = a.samplerate
pv = pvoc(win_s, hop_s) # phase vocoder
specgram = zeros([0, fft_s], dtype='float32') # numpy array to store spectrogram