#!/usr/bin/env python
# -*- coding: utf-8 -*-
#http://blog.csdn.net/myhaspl
#code:myhaspl@qq.com
import wave
import pylab as pl
import numpy as np
print 'http://blog.csdn.net/myhaspl'
print 'myhaspl@qq.com'
print
print 'working...'
print "read wav data...."
# 打开WAV文档
f = wave.open(r"speak.wav", "rb")
fo = wave.open(r"jg.wav", "wb")
fi=wave.open(r"back.wav", "rb")
# 读取波形数据
# (nchannels, sampwidth, framerate, nframes, comptype, compname)
params = f.getparams()
nchannels, sampwidth, framerate, nframes = params[:4]
str_data = f.readframes(nframes)
fi_params=fi.getparams()
fi_nframes = fi_params[3]
fi_str_data=fi.readframes(fi_nframes)
#将波形数据转换为数组,并更改
print "update wav data...."
wave_data = np.fromstring(str_data, dtype=np.short)
fi_wave_data= np.fromstring(fi_str_data, dtype=
python手记(46)
最新推荐文章于 2022-12-09 15:30:30 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)