Hello Community, I’m working with a PiCar-X and the Robot-Hat on a Raspberry Pi. I’m facing a permissions/configuration issue with the audio:
-
The hardware is OK: The example script
13.sound_background_music.pyworks perfectly when executed withsudo. -
The issue: When I try to play a sound as a normal user (named
jmcaneda) usingaplay -D plughw:2,0, there is no error in the terminal, but the speaker remains silent. -
Setup details:
-
User
jmcanedais already in theaudio,i2c, andgpiogroups. -
aplay -lcorrectly shows the card ascard 2: sndrpihifiberry. -
I’ve tried
chmod 666 /dev/snd/*with no success for the normal user. -
It seems the
picarx.musiclibrary or the hardware access requires root privileges to actually output sound.
-
Question: Is there a way to use the Robot-Hat speaker without sudo? This is critical for integrating audio into a larger Python project that doesn’t (and shouldn’t) run as root.
Thanks in advance!