import sounddevice as sd

def callback(indata, outdata, *stuff):
    outdata[:] = indata * [1, 0.5]
with sd.Stream(channels=2, callback=callback):
    pass
How to control a sound card programmatically?