在SciPy.IO.wav文件中我遇到了我的数据ndim问题

问题描述:

我有一个1维数组y,有132300个条目。在SciPy.IO.wav文件中我遇到了我的数据ndim问题

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 
+0

三江源非常多。我显然很缺乏经验! – 2012-01-08 20:50:08