gpt4 book ai didi

python - scipy.io.wavfile 给出 "WavFileWarning: chunk not understood"错误

转载 作者:太空狗 更新时间:2023-10-29 19:32:46 26 4
gpt4 key购买 nike

我正在尝试使用 scipy 读取 .wav 文件。我这样做:

from scipy.io import wavfile

filename = "myWavFile.wav"
print "Processing " + filename

samples = wavfile.read(filename)

我得到了这个丑陋的错误:

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/io/wavfile.py:121: WavFileWarning: chunk not understood
warnings.warn("chunk not understood", WavFileWarning)
Traceback (most recent call last):
File "fingerFooler.py", line 15, in <module>
samples = wavfile.read(filename)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/io/wavfile.py", line 127, in read
size = struct.unpack(fmt, data)[0]
struct.error: unpack requires a string argument of length 4

我正在使用 Python 2.6.6、numpy 1.6.2 和 scipy 0.11.0

Here's导致问题的 wav 文件。

有什么想法吗?这里出了什么问题?

最佳答案

这些文件不再可用(9 个月后不足为奇!),但为了将来引用,最可能的原因是它有 scipy 无法解析的额外元数据。

在我的例子中,它是由 Audacity 添加的默认元数据(版权、轨道名称等)- 您可以在 Audacity 中打开文件并使用文件...打开元数据编辑器来查看它。然后使用“清除”按钮将其删除,然后重试。

current version of scipy支持以下 RIFF block - 'fmt'、'fact'、'data' 和 'LIST'。 The Wikipedia page on RIFF有更多关于 WAV 文件结构的细节,例如你的文件可能包含一个不受支持但很受欢迎的信息 block

关于python - scipy.io.wavfile 给出 "WavFileWarning: chunk not understood"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14321627/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com