【问题标题】:In SciPy.IO.wavfile I am experiencing an issue with ndim of my data在 SciPy.IO.wavfile 中,我遇到了数据的 ndim 问题
【发布时间】:2012-01-08 18:36:17
【问题描述】:

我有一个一维数组 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'

我该如何解决这个问题?

谢谢。

【问题讨论】:

    标签: python io scipy waveform


    【解决方案1】:

    您传递的是字符串 'y' 而不是变量 y 作为数据参数。

    它应该像这样工作:

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

    【讨论】:

    • 非常感谢。我显然很缺乏经验!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多