# A way to use the Robot-Hat speaker without sudo, please

**URL:** <https://forum.sunfounder.com/t/a-way-to-use-the-robot-hat-speaker-without-sudo-please/4466>\
**Category:** Robotic kit for Raspberry Pi\
**Created:** [March 14, 2026, 12:04pm UTC](https://forum.sunfounder.com/t/a-way-to-use-the-robot-hat-speaker-without-sudo-please/4466 "2026-03-14T12:04:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmcaneda](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.sunfounder.com/jmcaneda/32/2234_2.png) [@jmcaneda](https://forum.sunfounder.com/u/jmcaneda)\
**Post date:** [March 14, 2026, 12:04pm UTC](https://forum.sunfounder.com/t/a-way-to-use-the-robot-hat-speaker-without-sudo-please/4466/1 "2026-03-14T12:04:11Z")

</div>

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:

1. **The hardware is OK:** The example script `13.sound_background_music.py` works perfectly when executed with `sudo`.

2. **The issue:** When I try to play a sound as a normal user (named `jmcaneda`) using `aplay -D plughw:2,0`, there is no error in the terminal, but the speaker remains silent.

3. **Setup details:**

**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!

---

<div class="post-metadata">

**Author:** ![Spf650](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Spf650](https://forum.sunfounder.com/u/Spf650)\
**Post date:** [March 14, 2026, 2:11pm UTC](https://forum.sunfounder.com/t/a-way-to-use-the-robot-hat-speaker-without-sudo-please/4466/2 "2026-03-14T14:11:00Z")

</div>

I believe its an alsa routing environment issue, I.e. root env vs user env, not privileges. So, try to add these 2 lines to the end of your ~/.bashrc

export SDL\_AUDIODRIVER=alsa

export AUDIODEV=hw:sndrpihifiberry

Then reboot.

Or, as a quick starting point just cut and paste the above 2 lines into your terminal before running….

```bash
python 9_howling.py # now without sudo!

```

.bashrc won’t work via cron, system services or autostarts as they won”t run your login. You’d need to place them somewhere appropriate to whatever your project requires, if different.
