How convert audio stereo to mono in python

3k Views Asked by At

I have no idea how to do this. I need to turn stereo audio into mono.

Can someone help me?

I'm using pygame to play the song

from pygame import mixer  
mixer.init()
mixer.music.load('meh.wav')
mixer.music.play()
2

There are 2 best solutions below

0
Lukasz Tracewski On

In general, you would simply load the audio into an array of shape (n, k), where n is number of channels and k number of loaded samples. By averaging along channel axis (sum and divide by number of channels), you'd get your mono signal.

In pygame there are at least two ways:

0
Marc Sturm Kenfack On

You can use a python interface of praat , parselmouth which guives a good estimation of Mono audio from stereo audio .

import parselmouth
from parselmouth import call
monoSound = call(sound,'convert To mono')