将TIMIT数据库中的Nist Wav文件读入python numpy数组 [英] Read Nist Wav File in TIMIT database into python numpy array
问题描述
这可能吗?从scikits.audiolab使用wavread时,似乎出现此错误:
Is this possible?? I seem to be getting this error when using wavread from scikits.audiolab:
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数组中吗?如果没有,那么读入数据的最佳方法是什么?
I'm guessing it can't read NIST wav files but is there another way to easily read them into a numpy array? If not, what is the best way to go about reading in the data?
可能会重写audiolab wavread以识别nist标头?
Possibly rewriting the audiolab wavread to recognize the nist header??
推荐答案
回答我自己的问题,因为已经解决了,但是您可以使用scikits.audiolab中的Sndfile类,该类支持多种读写文件格式,具体取决于libsndfile你有.然后,您只需使用:
Answer my own question because figured it out but you can use the Sndfile class from scikits.audiolab which supports a multitude of reading and writing file formats depending on the libsndfile you have. Then you just use:
from scikits.audiolab import Sndfile, play
f = Sndfile(filename, 'r')
data = f.read_frames(10000)
play(data) # Just to test the read data
这篇关于将TIMIT数据库中的Nist Wav文件读入python numpy数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!