这可能吗??使用来自 scikits.audiolab 的 wavread 时,我似乎遇到了这个错误:
x86_64.egg/scikits/audiolab/pysndfile/matapi.pyc in basic_reader(filename, last, first)
93 if not hdl.format.file_format == filetype:
94 raise ValueError, "%s is not a %s file (is %s)" \
---> 95 % (filename, filetype, hdl.format.file_format)
96
97 fs = hdl.samplerate
ValueError: si762.wav is not a wav file (is nist)
我猜它无法读取 NIST wav 文件,但是否有另一种方法可以轻松地将它们读取到 numpy 数组中?如果不是,读取数据的最佳方式是什么?
可能重写 audiolab wavread 以识别 nist header ??
最佳答案
回答我自己的问题,因为我已经弄清楚了,但您可以使用 scikits.audiolab 中的 Sndfile 类,它支持多种读写文件格式,具体取决于您拥有的 libsndfile。然后你只需使用:
from scikits.audiolab import Sndfile, play
f = Sndfile(filename, 'r')
data = f.read_frames(10000)
play(data) # Just to test the read data
关于python - 将 TIMIT 数据库中的 Nist Wav 文件读入 python numpy 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10187043/