我想读使用SciPy的一个* .wav文件。我执行以下操作:

import scipy
x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav')

作为该代码的结果获得:

Traceback (most recent call last):
  File "test3.py", line 2, in <module>
    x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav')
AttributeError: 'module' object has no attribute 'io'

请问有人知道这里有什么问题?谢谢你在前进。

有帮助吗?

解决方案

作为错误说,SciPy的模块不具有 'IO'。

io.wavfile是子模块,则需要from scipy.io import wavfile然后做wavfile.read("/usr/share/sounds/purple/receive.wav")

这让我与你正在使用作为一个例子文件的错误,但是...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top