Python: write a wav file into numpy float array

柔情痞子 提交于 2019-11-27 13:32:18

问题


ifile = wave.open("input.wav")

how can I write this file into a numpy float array now?


回答1:


>>> from scipy.io.wavfile import read
>>> a = read("adios.wav")
>>> numpy.array(a[1],dtype=float)
array([ 128.,  128.,  128., ...,  128.,  128.,  128.])

typically it would be bytes which are then ints... here we just convert it to float type

you can read about read here https://docs.scipy.org/doc/scipy/reference/tutorial/io.html#module-scipy.io.wavfile



来源:https://stackoverflow.com/questions/16778878/python-write-a-wav-file-into-numpy-float-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!