Data returned by scipy.io.wavfile.read

后端 未结 1 1105
长情又很酷
长情又很酷 2020-12-10 07:35

I\'m trying to get the data from a wav file in Python and plot it. When I use scipy.io.wavfile.read(), I get back an array that looks like this:

[[ -1.498367         


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 08:06

    The file you are reading seems to be a stereo file. These contain two-dimensional data - one track for the left and one track for the right speaker.

    The general concept is explained here: https://en.wikipedia.org/wiki/Stereophonic_sound

    If you want to select just the left audio channel from your two-dimensional data sequence, you can select it like

    y = samples[:,0]
    

    To select the right channel, replace the 0 with a 1.

    As an alternative, make sure that the program you use to generate the file saves mono wave files in the first place. Depending on what you are trying to do, this might be the actual bug.

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