import numpy as np
import pylab
wave_data =np.fromfile("C:\\Users\\Administrator\\Desktop\\bins\\4.b_le.bin", dtype=np.int16 , count=21220 )
wave_data.shape = -1,2
wave_data = wave_data.T
N=88200
start=0 #开始采样位置
df = 1000/(N-1) # 分辨率
freq = [df*n for n in range(0,N)] #N个元素
wave_data2=wave_data[0][start:start+N]
c=np.fft.fft(wave_data2)*2/N
#常规显示采样频率一半的频谱
d=int(len(c)/2)
pylab.plot(freq[:d-1],abs(c[:d-1]),'r')
pylab.show()