matplotlib.pyplot.specgram 。wav文件的时频分析(specgram)的函数。
语法:
[S,F,T,P]=spectrogram(x,window,noverlap,nfft,fs)
[S,F,T,P]=spectrogram(x,window,noverlap,F,fs)
当使用时无输出参数,会自动绘制频谱图;有输出参数,则会返回输入信号的短时傅里叶变换。当然也可以从函数的返回值S,F,T,P绘制频谱图,具体参见例子。
1)实例
from scipy.ioimport wavfile
import matplotlib.pyplotas plt
from matplotlib.pyplotimport specgram
##1、读取文件
sample_rate,X=wavfile.read("E:/test/hiphop.00001.au.wav")
print(sample_rate,X)
specgram(X,Fs=sample_rate,xextent=(0,30))
plt.xlabel("time")
plt.ylabel("frequency")
plt.show()
网友评论