How to specify the output channel (left,right) with pydub?

2.6k views Asked by At

I would like to see the same function found on pygame, channel.set_volume for pygame.mixer.sound. Example:

import pygame
pygame.init()

sound = pygame.mixer.Sound(name_of_the_file)
channel = sound.play()
channel.set_volume(1,1)     #That's what I need...  

I need it for a program that run o single computer and send information trough a speaker for each work office. Is there something similar on pydub? Thanks.

1

There are 1 answers

4
Jiaaro On BEST ANSWER

In the dev version of Pydub (on github) you can use the new apply_stereo_gain or pan method:

from pydub import AudioSegment
sound = AudioSegment.from_file("/path/to/sound.mp3", format="mp3")

# pan 10% left
panned1 = sound.pan(-0.1)

# left channel lowered 6 dB, right channel unchanged
panned2 = sound.apply_stereo_gain(-6.0, 0.0)