Home Assistant Better Sounding TTS

blargin ... Home Assistant TTS setup

Home Assistant Better Sounding TTS

Home Assistant TTS ( text to speech )

If you read my other post about getting your home assistant to give audio feedback, you would see its using pre-packaged TTS frameworks that generate audio from text. While that did work well it did not sound very natural or human like.

With the 0.35 update to Home Assistant they added text-to-speech, VLC capabilities.More info on the update is here.

With this update we are now able to get better audio files from Google, and use VLC player to play them.

If you have Google Home, or Sonos you can easily get TTS working without much effort. If you do not, or want to use the audio from your machine running Home Assistant the VLC player is a good option. Good info on how to get VLC player installed, if it is not already, can be found here: Install VLC for use with Home Assistant

So you want to get this all working? Make sure you have or update to Home Assistant 0.35 or newer.

After that you need to setup your config file.

Text to Speech Home Assistant Settings

The first thing we need to do is add the configuration setting to include TTS.

# Text to speech
tts:
  platform: google
  cache: true
  cache_dir: /tmp/tts
  time_memory: 300 

Media Player(s) Home Assistant Settings

Config using VLC

media_player:
  - platform: vlc
    name: vlc

Config using Sonos

media_player:
  - platform: sonos
    hosts: 
      - 192.168.1.33

Config using both VLC & Sonos

media_player:
  - platform: vlc
    name: vlc
  - platform: sonos
    hosts: 
      - 192.168.1.33

Now, all thats left is to use these settings with something.... for instance set up an automation service to use it. Something like:

    - service: tts.google_say
      data:
        message: "Mudroom Door Opened"    

So now, a full automation for a single media player might look something like:

    
  alias: Mudroom Door Opened Auto
  initial_state: True
  hide_entity: False
  trigger:
    platform: state
    entity_id: binary_sensor.mudroom_door
    state: 'on'
  action:  
    - service: tts.google_say
      data:
        message: "Mudroom Door Opened"

So now with that new setting, when the sensor is triggered "On" your Home Assistant will speak to you!

If you are like me, and have use for more than one media player you can use both.

    - service: tts.google_say
      data:
        entity_id: "media_player.vlc"
        message: "Test sensor opened" 
    - service: tts.google_say
      data:
        entity_id: "media_player.foyer"
        message: "Test sensor opened"    

*foyer is the name of the location of a Sonos speaker. You can check home assistant to see what is sees the names of your Sonos speakers as. While I do not have a Google Home, I assume it is very similar in how it works.

Tags

  • Home automation
  • Home Assistant
  • hardware

Add Comment