I'm using wavefile.read()
in Python to import a audio file to Python. What I want is read a audio file where every sample is in double and normalized to -1.0 to +1.0 similar to Matlab audioread()
function. How can I do it ?
Use read function of the PySoundFile package. By default it will return exactly what you request: a numpy array containing the sound file samples in double-precision (Float64
) format in the range -1.0
to +1.0
.
Use Scipy:
import scipy.io.wavfile as wav
fs,signal=wav.read(file_name)
signal /= 32767
You need to divided by max int if you want exactly the same thing as in Matlab. Warning: if the wav file is int32 encoded, you need to normalize by max int32
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With