pyxaudio provides audio support for Python on Linux. Audio processing is done using the FFmpeg library, Pulseaudio and Alsa can be used for playback. pyxaudio is intentionally kept basic and simple.
The version numbers merely reflect which versions I have been using during development.
import sys
import pyxaudio
# Open the playback sink.
sink = pyxaudio.Sink()
for url in sys.argv[1:]:
if sys.version_info.major == 2:
# pyxaudio needs all strings as unicode objects.
url = url.decode(sys.getfilesystemencoding())
# Create a new decoding source for the url.
source = pyxaudio.Source(url)
# Configure the sink.
sink.setup(source)
while True:
buf = source.read(8192)
if not buf:
break
sink.write(buf)
# Clean up.
source.close()
sink.close()