theamazingsplit
Posts: 1
Joined: Tue Jul 16, 2019 1:33 pm

[Solved] Python library to play OGG files using alsa for Headless RPi setup

Tue Jul 16, 2019 1:53 pm

Hello,

I'm working on an electronics project in which my raspberry pi 3 is connected to speakers and running Raspbian.
I'm seeking an audio library that will allow me to play OGG files using alsa that I can call in my existing Python code.

Said library would optimally have the following implemented : Pygame proposes exactly the solution I require, however, the event system is not compatible with my headless (no screen) setup. Other than that, the closest thing I've gotten is the combination of pydub and pyalsaaudio, but the basic functions I require (pause, unpause, stop, playing on specific channel, track done event) are not implemented and I'm having a lot of trouble implementing them.

What I have tried already, and my results :

| Software | Tested | Works? | Explanation | Link |
|:--------------------|:------:|--------:|-------------------------------:|-------------------------------------------------------------------:|
| pyaudio (+pydub) | Yes | No | Doesn't use alsa | https://people.csail.mit.edu/hubert/pyaudio/ |
| mpyg123 | Yes | No | Doesn't play sound | https://github.com/4br3mm0rd/mpyg321 |
| pyalsaaudio | Yes | No | No OGG support | https://github.com/larsimmisch/pyalsaaudio |
| vlc | Yes | No | Requires video | https://pypi.org/project/python-vlc/ |
| pygame | Yes | No | Requires video | https://pygame.org |
| pydub + pyalsaaudio | Yes | Sort-of | Doesn't implement the basic functions I need | https://github.com/jiaaro/pydub/ |
| PyOgg + PyOpenAL | Yes | No | Runtime errors | https://github.com/Zuzu-Typ/PyOgg, https://github.com/Zuzu-Typ/PyOpenAL |
| music-player-core | Yes | No | Doesn't build | https://github.com/albertz/music-player-core |


It's been a few weeks I've been attacking this problem - any ideas are appreciated. Thank you in advance for your help !

Solution VLC controlled by Python code.
Documentation : https://www.olivieraubert.net/vlc/python-ctypes/doc/
Library : https://pypi.org/project/python-vlc/

Return to “Graphics, sound and multimedia”