我有一个一维数组 y,有 132300 个条目。
print y.ndim
给我 1。
现在,当我使用 write('440saw2000.wav', '44100', 'y') 时,我收到以下错误消息:
Traceback (most recent call last):
File "C:\Users\Matt\The Mathematics Of Digital Synthesizers\Scripts\filter.py", line 47, in <module>
write('440saw2000.wav', '44100', 'y')
File "C:\Python27\lib\site-packages\scipy\io\wavfile.py", line 161, in write
if data.ndim == 1:
AttributeError: 'str' object has no attribute 'ndim'
我该如何解决?
谢谢。
最佳答案
您正在传递字符串 'y' 而不是变量 y
作为数据参数。
它应该像这样工作:
write('440saw2000.wav', 44100, y) # without quotes around y and 44100
关于python - 在 SciPy.IO.wavfile 中,我遇到了数据 ndim 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8780126/