Can't get scipy.io.wavfile.read() to work

后端 未结 1 1099
挽巷
挽巷 2021-01-18 03:55

I am trying to read a .wav file into an array so that I can then plot the array and do a FFT. I got the file open with the wave module and now I am struggling. I was advised

1条回答
  •  迷失自我
    2021-01-18 04:43

    You have confused SciPy's WAV module with Python's. Remove import wave, use import scipy.io.wavfile, and call scipy.io.wavfile.read.

    Example:

    >>> import scipy.io.wavfile
    >>> FSample, samples = scipy.io.wavfile.read('myfile.wav')
    

    SciPy's module does the job of converting from a byte string to numbers for you, unlike Python's module. See the linked docs for more details.

    0 讨论(0)
提交回复
热议问题