Python: write a wav file into numpy float array

IAM picture IAM · May 27, 2013 · Viewed 30k times · Source
ifile = wave.open("input.wav")

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

Answer

Joran Beasley picture Joran Beasley · May 27, 2013
>>> 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