寻找在python中读取音频波形值

时间:2015-02-18 15:06:46

标签: python audio

我试图读取和操作音频文件, 如何使用python读取和操作wave文件的wave值?

1 个答案:

答案 0 :(得分:0)

SciPy libraries有很多资源:

  

写作和阅读:   

import numpy as np
from scipy.io import wavfile

fs = 44.1e3
t = np.arange(0, 1.0, 1.0/fs)

f1 = 440
f2 = 600

x = 0.5*np.sin(2*np.pi*f1*t) + 0.5*np.sin(2*np.pi*f2*t)

fname = 'output.wav'
wavfile.write( fname, fs, x )


fs, data = wavfile.read( fname )

print fs, data[:10]
  

文档:   http://docs.scipy.org/doc/scipy-0.14.0/reference/io.html#module-scipy.io.wavfile

之前已经问过这个问题:Reading *.wav files in Python