How to play a sound through the RPI speaker with Hass.io?

Hi,
Is it possible play a sound through the RPI speaker with Hass.io?
How would one do that?
thanks,
chris

I never did something like this, but maybe this is a solution: Play audio file for door announcement

Thank you for the tip Recte. Indeed, this seems like something that may work
I added the mopidy addon
When i start it, I get:
OSError: [Errno 2] No such file or directory: '/share/mopidy/playlists'
I’m not sure where the add on is looking for that directory, and/or if it is mapped from inside the container to the host
I’ll open a separate question for that
thanks
chris

SOLVED:
Additional info on how to add/configure the mopidy AddOn:

In my setup the share directory was expected to be under /usr/share/hassio/
(All those different deployment models are quite confusing for a simple newbie like myself)

sudo mkdir -p /usr/share/hassio/share/mopidy/playlists 
sudo mkdir -p /usr/share/hassio/share/mopidy/media 

chrisV

Hi, all

Currently running home assistant on a RPI4 and for some reason I got consistently stuck in the installation of mopidy (apparently no release candidate for ARM and the custom repos weren’t working for me), so I ended up finding this rather simple solution using a community VLC plugin that I hope will help someone else.

  1. Supervisor > Addon Store > Add custom repository hassio-local-vlc/local-vlc at master · rodripf/hassio-local-vlc · GitHub and install the add-on.
    The GIT includes detailed instructions on setting it up. Make sure to enable telnet and define a password in the addon-config section.

  2. Add this line to your configuration.yaml

media_player:
  - platform: vlc_telnet
    host: 127.0.0.1
    password: whateverPasswordYouSetBefore
  1. Restart Home Assistant.

At this point you should have a working entity called VLC-TELNET. You can rename it by adding a “name” property to the config.

You can now play TTS using the media dashboard component and even better you can playback MP3 or WAV files by calling a service as shown below.

Please note that media files need to be uploaded to the /share folder (you can use the samba add-on to upload the files there).

Happy automating fellas!

1 Like

Hi, thank you for the solution. So far this is the only working solution for rpi 4. My home assistant havily relay on tts for feedback. This year I have upgrade from rpi 3 to rpi 4. Before I was using mopidy, and it was working fine. But I have a problem with this (vlc) addon. When starts to read/speak the message for the first 4 or 5 seconds the sound is very choppy. Some times I can not hear whole words. I have changed the sd card for ssd. My rpi 4 has 8 gb of ram. Do you have the same problem?

Yeah, I noticed the same issues after the setup and thought it could be my audio files. I worked around it by putting 1 second of empty space before the beginning of the audio files. Then I found that wav 44Khz exported from Audacity didn’t stutter so much but it’s hit and miss.

Gays, I found a mopidy version that is compatible with Raspberry Pi 4. Now the tts is smooth. In order to install it you need to add this repo: GitHub - Poeschl/Hassio-Addons: The repository for my Home Assistant Supervisor Add-ons.

I tried it for my rpi4 too but it seems there’s a problem with the output device, showing dummy output and I don’t listen anything. Any suggestions?

I followed your instructions but it is not working, I tried uninstalling and installing again. modifying the config but no luck. could it be unsupported?
I have a raspberry pi 3. could that be the reason?

[0000007fa80e1980] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[0000007fa80e1980] main interface error: no suitable interface module
[0000007fa822cb50] main libvlc error: interface "dbus,none" initialization failed
[0000007fa80e8040] main interface error: no suitable interface module
[0000007fa822cb50] main libvlc error: interface "globalhotkeys,none" initialization failed
[0000007fa810a9e0] main playlist: playlist is empty
[0000007fa80e8040] [http] lua interface: Lua HTTP interface
[0000007fa80e1ae0] [telnet] lua interface: Listening on host "telnet://:4212".

missed this part

" Run a VLC player on your hass.io installation.

Control it using the web interface or with the new VLC Telnet component and control the player from your HA Automations!"

I installed the VLC Telnet Component and it works now after installing local VLC first

Edit:
It even works though HDMI out

I didn’t have to do anything to my config file and it worked.

1 Like