Skip to content

Instantly share code, notes, and snippets.

@multivac61
Created December 18, 2015 11:10
Show Gist options
  • Save multivac61/4844b58a9c4594102c2d to your computer and use it in GitHub Desktop.
Save multivac61/4844b58a9c4594102c2d to your computer and use it in GitHub Desktop.
def freq_from_CEPS(sig, fs):
N = len(sig)
windowed = sig * blackmanharris(N)
spectrum = np.fft.rfft(windowed, fs)
spectrum[spectrum == 0] = EPSILON
log_spectrum = np.log(np.abs(spectrum))
ceps = np.fft.irfft(log_spectrum)
start = int(fs / HIGH_FREQ)
end = int(fs / LOW_FREQ)
i_peak = np.argmax(ceps[start:end])
i_interp = interpolate(ceps[start:end+1], i_peak)[0]
return fs / (i_interp + start)
@rizwanishaq
Copy link

the interpolate function is part of numpy/scipy???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment