我想读左边和右边的频道。在
import wave
origAudio = wave.open("6980.wav","r")
frameRate = origAudio.getframerate()
nChannels = origAudio.getnchannels()
sampWidth = origAudio.getsampwidth()
nbframe=origAudio.getnframes()
da = np.fromstring(origAudio.readframes(48000), dtype=np.int16)
origAudio.getparams()
参数
^{pr2}$现在我想用24位数据中的wave文件分离左右声道
您可以使用^{} ,这是一个小模块,我用numpy数组读写WAV文件。在您的情况下:
^{} is on PyPi ,源代码在github上的https://github.com/WarrenWeckesser/wavio。在
参数告诉你,你有2个通道的数据,每个采样3字节,在48kHz。因此,当你说
readframes(48000)
时,你会得到一秒钟的帧,你应该读入一个稍微不同的数据结构:现在应该有48000*2*3字节,即
^{pr2}$len(da)
。要只接收第一个频道,请执行以下操作:也就是说,创建一个整数数组,每个样本一个,然后从源数据复制适当的字节(可以尝试直接从
readframes()
的结果复制,而跳过创建da
)。在相关问题 更多 >
编程相关推荐