我想使用 Python 访问一个 wav 文件并以允许我分析它的形式写入它的内容(比如说数组)。
- 我听说“audiolab”是一个合适的工具(它将numpy数组转换为wav,反之亦然)。
- 我已经安装了“audiolab”,但是 numpy 的版本有问题(我不能“从 numpy.testing 导入测试器”)。我有 1.1.1。numpy 的版本。
我在 numpy (1.4.0) 上安装了更新版本。但后来我得到了一组新的错误:
Traceback(最近一次调用最后):文件“test.py”,第 7 行,在 import scikits.audiolab 文件“/usr/lib/python2.5/site-packages/scikits/audiolab/init .py ”,第 25 行,从 pysndfile 导入 formatinfo,sndfile 文件“/usr/lib/python2.5/site-packages/scikits/audiolab/pysndfile/init .py ”,第 1 行,从 _sndfile 导入 Sndfile,格式,available_file_formats,available_encodings 文件“numpy .pxd",第 30 行,在 scikits.audiolab.pysndfile._sndfile (scikits/audiolab/pysndfile/_sndfile.c:9632) ValueError: numpy.dtype does not seem to be the correct type object
我放弃了使用 audiolab 并认为我可以使用“wave”包来读取 wav 文件。我问了一个问题,但人们建议改用 scipy。好的,我决定专注于 scipy(我有 0.6.0. 版本)。
但是当我尝试执行以下操作时:
从 scipy.io 导入 wavfile
x = wavfile.read('/usr/share/sounds/purple/receive.wav')
我得到以下信息:
Traceback (most recent call last):
File "test3.py", line 4, in <module>
from scipy.io import wavfile
File "/usr/lib/python2.5/site-packages/scipy/io/__init__.py", line 23, in <module>
from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest
- 所以,我放弃了使用 scipy。我可以只使用wave包吗?我不需要太多。我只需要具有人类可读格式的 wav 文件内容,然后我会弄清楚如何处理它。