Python Forum

Full Version: Playing mp3 file to specific device
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm new to python but want to try converting an ESP32 project to work on a Raspberry pi and most suggestions say python is the way to go for IoT development on a Pi.

One of the things my project deals with is playing sound effects based on various triggers and events. I would prefer to store the files in mp3 format as they are smaller and the tags allow me to include details on what the files contain. (I'm pulling them -- with the author's permission -- out of an audiobook. so I try to keep track of what page/chapter they come from, who the speaker is, what the basic context is, etc)

The problem is that on a Pi, I ended up getting an external board for the DAC playback which means it isn't necessarily going to be the default system playback device. Also, since this is being built on a Pi Zero, I have the option to use bluetooth connections. I would like to be able to select which device is going to be the target for the playback of the sounds. (possibly even the default HDMI audio output as a potential option)

I will likely use some kind of a web interface in addition to scripts that will be running at boot-up to handle the various behaviors and settings. So it would read device information (current chosen playback device) from some kind of a data file (probably json data or an .ini format)

I can find examples on playback using any number of libraries or system calls. I can find examples of device selection using sounddevice. But I can't seem to find any mp3 specific playback examples that target a specific alsa device. (the dac board is seeedstudio voicecard which uses an alsa driver and shows up as device 2)

Thanks in advance for any assistance.
try looking here: https://pypi.org/
Thanks, I've been looking for a link like that. I have been wondering if there was anything equivalent to Arduino Playground for Pi/Python
Pypi.org can be searched like google.
You can search yourself as there are 173,453 projects.
Ok to ask as well, because some moderators may have used some of the packages, but look first.
Search for 'Arduino Playground' brings up: https://pypi.org/search/?q=Arduino+Playground

One thing to look at is last date updated.
If this date is really old, that means the code is out of date, and probably was abandoned.
Anyone can post a package to PyPi, so sometimes are abandoned/ Nevertheless, There are some excellent packages available.
You can choose 'Trending' in order by pull-down. To see what's being downloaded the most.