Created
December 4, 2015 12:21
-
-
Save utahka/1e5c532d43befb1fb989 to your computer and use it in GitHub Desktop.
Plot a cepstrum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import scipy.fftpack | |
import scipy.io.wavfile | |
import numpy as np | |
import matplotlib.pyplot as plt | |
if __name__ == "__main__": | |
wav_file = sys.argv[1] | |
f_s, x = scipy.io.wavfile.read(wav_file) | |
N = 2048 | |
""" | |
T = N / f_s | |
where, T[sec] is window size. | |
""" | |
X = scipy.fftpack.fft(x[:N]) | |
X = scipy.fftpack.fftshift(X) # リストの順を自然なものに変更 | |
log_amp_spectrum = np.log10(np.abs(X)) | |
cepstrum = np.real(scipy.fftpack.fft(log_amp_spectrum)) | |
quefrency = np.arange(0, N) # ケフレンシーの取得 | |
plt.plot(quefrency[quefrency.size//2: ], cepstrum[quefrency.size//2: ]) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment