How do I go about playing 2 different mp3 files from two different USB sound cards? The mp3 files are stored locally and I would like to use python script to choose a file and play it on one of the two sound cards?

I found through some browsing over the internet about pulseaudio. If I install pulseaudio and create two sinks ,one USB sound card each, will I be able to select a sink and play a file choosing a sink from python? What package/library would I need in python to interface with pulseaudio sinks?


  • is this possible with pymad and pyaudio together? May 21 '14 at 17:06
  • How do I select soundcard in pyaudio May 21 '14 at 17:13

You could try using a python library that simply may execute terminal commands and then use pactl to upload an audio sample via pactl upload-sample FILENAME [NAME] and playback via pactl play-sample ID SINK.

Be sure the python process is run by a user that can control pulseaudio, and is part of the groups audio, pulse, and pulse-rt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.