2012-01-08 96 views
2

我有一個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' 

我該如何解決這個問題?

謝謝。

回答

1

您傳遞字符串'y'而不是變量y作爲數據參數。

它應該是這樣的:

write('440saw2000.wav', 44100, y) # without quotes around y and 44100 
+0

三江源非常多。我顯然很缺乏經驗! – 2012-01-08 20:50:08