TTS using built in RPi3 analogue audio output with Hassio?

Hello!

I’m trying to figure out how to get text to speech to use the built in 1/8" audio output of the raspberry pi 3 using HASSIO. Ultimately, I want to send sensor alerts, and alarm notifications through this analogue audio output.

Have I completely overlooked something simple?

1 Like

Okay, I’ve got the answer!

I’ve consolidated these instructions based on my needs, to get generated tts audio out of the local raspberry pi 3 audio output using hass.io. Many thanks to this thread, and specifically @richardgewy.

Instructions

  1. Install the “modipy” addon using the /hassio/store Add-On Repositories section, this might take a bit, be patient
  2. Start the service
  3. Add the configuration below to your configuration.yaml file and SAVE
# Mopidy addon for hass.io
media_player:
  platform: mpd
  host: YOUR.HOST.IP
  1. Restart your server
  2. Now you can use media_player.mpd as the entity_id to send tts audio to, I use google text to speech (tts)
  3. To test, you can go to your hassio Services (looks like a remote icon)

Domain:

tts

Service:

google_say

Service Data:

{
"entity_id":"media_player.mpd",
"message":"Hello Brian, how are you today?"
}

Then click Call Service and you should hear tts generated audio output to your RPi3’s audio output jack!

I hope this helps someone!

7 Likes

i can’t find that add-on on the hass.io store

You can also run VLC directly on your PI and then just have it setup as the media player and send the TTS to it when required.

It’s not in the store by default, you add the link.

Can VLC be installed on hassio? I thought it couldn’t. Or if it can, will it support the existing analogue output?

can you post the actual link to put it on the box i couldnt find it

Yes. I’ll be home in a couple of hours and I’ll check and post it.

by the way thank you for sharing

1 Like

@Kem You can use the same link I posted above, it was within the “modipy” text:

  1. Add this to your add-on repositories: https://github.com/bestlibre/hassio-addons
  2. Click, “Save”
  3. Scroll down and you should see “BestLibre addons repository”
  4. Install “Mopidy”
  5. Continue with the previous instructions #2

it worked thanks again

Thiis worked exactly as you say. I note however that after the first audio that is played, the speakers emit a white noise (as though the volume is turned up 100%). Do you now how to adjust the volume for the RPi3 and reset it to default once audio has been played?

Worked absolutely flawlessly!

EDIT: what was i saying…

The on board Pi audio isn’t very good quality, the assumption being sound would be going out of HDMI or a USB card.

Of course, I haven’t been able to figure out how to get mopidy in Hass.io to send audio to a USB sound card.

I’m not sure if this works with Hassio, but try this on the command line:

alsamixer -c 1

Thanks. Doesn’t appear as though alsamixer is available on HassIO :frowning:

I install mopidy as described and it’s working. I can open web-client and play mp3 stored in share/mopidy map. But I have a problem with google tts. When i call service with message i get error in mopidy log and no sound from speaker:

WARNING  Download of u'https://xxxx.duckdns.org:8123/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3' failed: HTTPSConnectionPool(host='xxxx.duckdns.org', port=8123): Max retries exceeded with url: /api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3 (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x74a25ff0>: Failed to establish a new connection: [Errno 111] Connection refused',))
INFO     Unwrapping stream from URI (https://xxxx.duckdns.org:8123/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3) failed: error downloading URI https://xxxx.duckdns.org:8123/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3
WARNING  Problem looking up https://xxxx.duckdns.org:8123/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3
WARNING  Download of 'https://xxxx.duckdns.org:8123/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3' failed: HTTPSConnectionPool(host='nightbodom.duckdns.org', port=8123): Max retries exceeded with url: /api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3 (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x71292ad0>: Failed to establish a new connection: [Errno 111] Connection refused',))
INFO     Unwrapping stream from URI (https://xxxx.duckdns.org:8123/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3) failed: error downloading URI https://xxxx.duckdns.org:8123/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3
WARNING  Track is not playable: https://xxxxx.duckdns.org:8123/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en-uk_-_google.mp3

I read about problems TTS have with let’s encript and duckdns… I try with different base_URL options, but no success…

Any help would be appricated

I have the opposite problem. Done the Modipy installation as described above. The TTS is working on my local USB speakers but I battle with playing a local mp3 file.

I load an mp3 file in the directory /share/mopidy/media/
And a playlist file with one of the mp3’s in /share/mopidy/playlists/

Tried a couple of options but no sound on the usb speaker
entity_id: media_player.mpd
media_content_type: music
media_content_id: /share/mopidy/media/test.mp3

or

  entity_id: media_player.mpd
  media_content_type: playlist
  media_content_id: testlist

The only option that played the mp3 on the speaker was:
(In this test the mp3 for this test was in the www directory)

media_content_id: https://my-domain.duckdns.org:8123/local/test.mp3

Does it mean I can only play a local mp3 if I have an internet connection?

I disable let’s encript, duckdns, etc. but still the same problem… mopidy is working through web-client but tts just don’t work.

I try to play mp3 with service in HA but it generate error:
Error doing job: Task exception was never retrieved
20:57 components/media_player/mpd.py (ERROR)

Ok I finaly found solution. It was problem with base_url and NAT loopback. My router doesn’t support NAT loopback so it was problem when mopidy try to play tts from xxxx.duckdns.org:8123

I don’t know how to deal with NAT loopback problem (any sugestions?) so I try somethig else:
I change base_url to hassio_IP:8123 and mopidy has no problem playing tts.

Well… a don’t know if changing base_URL to hassio_IP:8123 instead of xxx.duckdns.org:8123 will affect any other devices in HA but for now it looks good?!?

Another thing is playing mp3 in services…

This also didn’t work for me… produce some errors because it couldn’t find file

This works for me:
{
“entity_id”: “media_player.mpd”,
“media_content_type”: “music”,
“media_content_id”: “local:track:test.mp3”
}

Hope it’s useful for someone…