python - 将 TIMIT 数据库中的 Nist Wav 文件读入 python numpy 数组

标签 python numpy scipy speech-recognition

这可能吗??使用来自 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/

相关文章:

python - 用零替换足够小的值的快速方法

python - 运行基于 OpenMPI 的库时出错

python - 如何在 Mac OS 10.7 上启动 Python 的开发环境 IDLE?

python - 错误 : [Errno 98] Address already in use

python - scrapy django 使用抓取的数据更新数据库

python - 二维 numpy 数组列中的唯一条目

python - 数组乘以标量的意外结果

python - 在python中更改数组的数据类型

python - 如何序列化 CSR 矩阵

python - 列表列表到 ndarray