基于python3下wav文件的时域图
发布日期:2022/8/23 16:59:29 浏览量:
基于python3下wav文件的时域图
import wave as we
import numpy as np
import matplotlib.pyplot as plt
def wavread(path):
wavfile = we.open(path,"rb")
params = wavfile.getparams()
nchannels,samplewidth,framerate,nframes=params[:4]
datawav = wavfile.readframes(nframes)
wavfile.close()
wave_data = np.fromstring(datawav,dtype = np.short)
if nchannels==1: wave_data.shape=-1,1
if nchannels==2: wave_data.shape=-1,2
wave_data = wave_data.T
time = np.arange(0, nframes) * (1.0/framerate)
return wave_data[0],time
path = "1.wav"
wavdata,wavtime = wavread(path)
plt.plot(wavtime, wavdata,color = ’blue’)
plt.show()
业务实施流程
马上咨询: 如果您有业务方面的问题或者需求,欢迎您咨询!我们带来的不仅仅是技术,还有行业经验积累。
QQ: 39764417/308460098 Phone: 13 9800 1 9844 / 135 6887 9550 联系人:石先生/雷先生