TTS questions

So I’ve been looking at TTS, not for some really important automation, but rather because I want to try and see where I can use anything and everything on HA just to see it work. Of course once I can do it well then I might actually find some valuable use for it hahaha.

TTS has fascinated me for a while now but I’m still unsure of a few (probably) basic setup rules. so let me ask these stupid questions please.

  • Do you have to have a speaker or some form of media player connected directly to the device running HA? Mine is on a RP3

  • All my audio is currently played through my tv soundbar where I run my main PC from. Can I somehow use this as a means to play TTS mp3s acknowledging that it has to be one to do so of course?

I’ll be honest in saying at this stage I’d love TTS to simply say “it’s Saturday night, movie night” for the kids but if I could make that work I could see so many other really positive ways I could implement TTS into automations in future.

You can use a PI with a speaker or you can do what I am doing and send TTS notifications to another device. Typically most of my TTS is sent to my Google Home, but I could send it to one of my Chromecast devices. Since I have a TTS app on my phone, my Pushbullet notifications are automatically read out.

For example, this is the notification for my clothes dryer:

# Dryer Notification Sequence Done 
- alias: 'Dryer Done - home'
  trigger:
    platform: state
    entity_id: sensor.aeotec_smart_switch_6_power_11_8
    state: '0.0'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.dryer_switch
        state: 'on'
      - condition: state
        entity_id: device_tracker.rpitera_rpitera
        state: 'home'
  action:
    - service: tts.google_say
      entity_id: media_player.living_room_home
      data:
        message: 'The dryer is finished Robert.'
    - service: input_boolean.turn_off
      entity_id: input_boolean.dryer_switch

which app on your Phone does automaticly speak a notification?

i have lannouncer on my tablet but it doesnt run on my (android) Phone.
(hmm, if i remember correct you dont have android, so your answer wouldnt help me then :wink: )

I am using TTS on my RPi3 (which hosts Home Assistant ). Here is a walktrough to make everything work

First you have to install a media player. I use VLC:
sudo apt-get install vlc-nox
Then add Hass to audio group:
sudo usermod -a -G audio homeassistant

I also use the following to increase the volume of the output to 100%

In HA, I have declared the media player using

media_player:
  - platform: vlc
    name: speaker_1
    arguments: '--alsa-audio-device=hw:0,0'

And finally I declare google tts and use it to wish me goodnight (for instance)

- alias: 'Say good night'
  service: tts.google_say
  entity_id: media_player.speaker_1
  data_template:
    message: >-
      {{ [
      "Good night. " ,
      "Good evening. " ,
      "Sweet dreams. " ,
      "See you tomorrow. " ,
      "Have a wonderful night. " ,
      "See you soon. " 
      ] |random }}

Obviously, that is some simple example. My most useful TTS is my ‘morning routine’ : It greets me, then speak the weather forecast (scraped for the website of my local weather institute) and tells the min an max temperatures expected, then tells me how long is the commute to work, tells different messages depending on the reminders I have set (like buy some bread, take off the wet clothes from the machine), and finally it tells me about my appointment for the day

10 Likes

Nope, I have Android. I’ve been using this since my first smartphone years ago. It was the first app I bought and one of the first I install on every new device. Works flawlessly, endlessly customizable and updated frequently.

You can even make it work with third party TTS libraries if you don’t like the one built into Android.

https://play.google.com/store/apps/details?id=ekawas.blogspot.com&hl=en

1 Like

thanks ill keep it in mind.

Did you setup your TTS or chromecast in a special way?
Cause If I run your script, it just saves the generated mp3 into the tts folder and the chromecast device goes into idle mode. Normal streaming to my chromecast audio devices is working. I’m using hass.io, could that be the problem?

Is your speaker_1 connected directly to your Pi?

Hmm, I’ve never set it up to work on VLC, but as far as setting it up for a media player device like google home, all I did was set up Google TTS according to these docs -

  • and specified my ghome as the target device as shown above.

Yep. Cheap speaker from aliexpress connected with jack cable. I only use it for tts so it sufficient

It was a problem with my configuration for Hass.io.

If I set the base_url to: 127.0.0.1:8123 it’s not working. if I put in the actual url (192.168.0.13:8123), it works!

1 Like

Perfect, that’s my plan then. I’m thinking a small usb powered speaker might be good, if the RP# has powered usb ports that is

1 Like

Howdy. Thanks for the tutorial! Is there any way to set the default volume on the pi to 100%? just had lightning strike nearby and it knocked the power out just as i finished setting up the speaker. When I tested it again, the volume was set right back to very low.

I do not really know. Probably you could do some bash script that executes at bootup and that increses the volume, but I am a noob when it comes to the raspberry pi itself, so I can’t help you more on that. The tips I said in my previous post are just a compilation of the different stuff I found after a few hours of research. Currently I do not have the time nor the need to dive into it more, so it just stays like this in my setup :wink:

Understood. Guess I’ll have to do some reading. Thanks for the response!

1 Like

Finally got organised and ordered a cheap speaker to hook directly up to my pi and install VLC as per your instructions.

Bit confused on the arguments though. What info is given to tell HA that VLC is on the pi and using the speaker in question?

media_player:
  - platform: vlc
    name: speaker_1
    arguments: '--alsa-audio-device=hw:0,0'

So HA knows it has to check for vlc… and as the pi tdetects the speaker in jack output, everything works fine. For the last line (arguments:…) I really do not know why it should be that, but after hours of checking what to put, I found this and it works… Basically a " don’t know/don’t care" approach :smiley:

Let me share some information.
Try to use “aplay -L” command to get list of available audio devices. With “aplay -l” you can see the default one. Sometime the plughw device is more preferable then hw. The “alsamixer” utility is helpful when you want to increase output volume. Use “sudo alsactl store” to fix it. It is possible to use following commands to test sound output via audio jack or hdmi on raspberry:
speaker-test -c2 -D plughw:0,0 --test=wav -w /usr/share/sounds/alsa/Front_Center.wav
or
speaker-test -c2 -D plughw:0,1 --test=wav -w /usr/share/sounds/alsa/Front_Left.wav

More details could be found on http://www.volkerschatz.com/noise/alsa.html

4 Likes

I like that reasoning

ok, I’m testing this all and I’m getting nothing to my speaker. My automations create the mp3 files in my tts folder so that end is going right.

But re-reading everything I am wondering if my issue is that my RP3 has a HDMI cable attached as well as the 3.5 jack. I have all this hooked up to my tv and pc in the lounge room. I keep the pi attached to the tv via HDMI so I can actually log on to the pi and do things at times, although it’s rare as I usually SSH via Putty.

I’ve run “aplay-l” but I’m not sure exactly what I’m looking at to ensure I’ve got the right output and thus arguments.

is the best option to simply remove the HDMI cable?