Johncowk
Johncowk

Reputation: 369

Output of scipy's wavfile.read function

I tried using the scipy.io.wavfile.read function the get the soundpressure of a soundtrack and get, as indicated in the doc two outputs : the sampling rate and a data numpy array. So far so good.

My problem is that the output array is (Nx2) dimensional and I don't know what the two dimensions represents. I was expecting to get a (Nx1) dimensional array with the total number of samples.

I have looked online and didn't find anything, and even after converting the audio signal to mono, I still get a Nx2 array so I don't think these are the left and right channel (but I could be wrong).

running the following code :

scipy.io.wavfile.read(path+"slow_jazz.wav")

gives the following output :

(44100, array([[-1.37977577e-06,  8.62224842e-05],
   [ 1.10934685e-04, -1.24923863e-05],
   [ 3.23722816e-05,  6.47113484e-05],
   ...,
   [ 2.37652988e-04,  1.36341288e-04],
   [ 2.67631025e-04,  2.15149150e-04],
   [ 2.91718607e-04,  2.33943792e-04]], dtype=float32))

Any idea what's going on ?

Upvotes: 1

Views: 1082

Answers (1)

Jon Nordby
Jon Nordby

Reputation: 6299

The last dimension is the number of channels. 2 means that you have a stereo wav file as input.

Upvotes: 1

Related Questions