How to configure Piper as a standard TTS in automations

Yep, I discovered that too. Not really a terrible solution, but I will probably put in a ticket for this. If I re-run the automation within a few minutes, it picks up where it left off last. Sometimes it is able to get through the entire script, which takes about 3 minutes, but I believe that is only because so much of the automation was cached at that point. I could be wrong.

In the mean time, I’ll just break up the automation with delays, but will open a ticket as well. There are no errors in the logs.

One last thing, I have to surround the TTS script with quotes due to formatting, and the voice ends the with a “heh” sound after it is done reading everything. I’ll add that to the ticket as well.

2 Likes

Okay, I discovered that removing quotes from the section under message: > removes the “heh” at the end of the TTS message. Easy enough (see below):

data_template:
  message: >
    "My message that makes a heh sound at the end."
data_template:
  message: >
    My message that does not make a heh sound at the end.

That’s YAML. If you use > (or |), quotes are included inthe string, rather marking start/end of it.

data_template:
  message: >
    "My message that makes a heh sound at the end."

is the equivalent of

data_template:
  message: "\"My message that makes a heh sound at the end.\""
1 Like

It is unclear if you opened an issue or not, but a related issue on github multi-line prompt causes prompts and outputs to become mis-aligned has a fix on the way, pull request approved Fix Piper multi-line, voice checksum. I also had a long script that worked with tts.cloud_say but not tts.speak

About the original question - in case someone else also finds this via Google later - the default model to use in Piper is configured in the Piper Addon configuration in the HAOS. So HA → Settings → Addons → Piper → Configuration → Voice. I also needed to “Reload” the Piper entity provided by the Wyoming integration for the voice list to be correct.

1 Like

Just wondering if anyone has worked out how to queue piper in a tts automation. At the moment I have an announcement every morning (that varies in length) after which the radio plays. however the radio starts playing as piper is reading out the announcement?

Hi @Garyw
You can use the custom Chime TTS integration. If you use it in a sequence before the radio it will play your TTS message, delay the sequence, and then the radio should start playing with the right length of delay.

Great, ok I will give it a shot

Does anyone know how to use the length_scale option in piper through the tts.speak service?

I tried this but it gives an error:

  - service: tts.speak
    data:
      message: "this is a test"
      cache: false
      media_player_entity_id: media_player.media_player_daemon_epic_announce
      options:
        voice: en_US-libritts-high
        speaker: 0
        length_scale: 0.5
    target:
      entity_id: tts.piper

“Failed to call service script/tts_test. Invalid options found: [‘length_scale’]”

Hey everyone, I’m a n00b but somehow managed to get it work. You can also adjust the message based on states and entity attributes (as probably many of you want like me).

Quite interestingly, you set the language via voice (and not language attribute). For me it was sk_SK-lili-medium (you get options for this from piper config).

Here’s my code also with some message bloat you can remove. You can test in web developer services debug.

service: tts.speak
data:
  message: >-
    {% set t = states('weather.domov_2') %}
      {% if  t == 'cloudy' %} {% set t='oblačno' %}
      {% elif  t == 'sunny' %} {% set t='slnečno' %}
      {% elif  t == 'rainy' %} {% set t='dážď' %}
      {% elif  t == 'snowy' %} {% set t='sneh' %}
      {% elif  t == 'partlycloudy' %} {% set t='polooblačno' %}
    {% endif %} Vonku je {{ t }}, {{ state_attr('weather.domov_2','temperature')
    }} stupňov a vlhkosť je {{ state_attr('weather.domov','humidity') }}
    percent. Rýchlosť vetra je {{ state_attr('weather.domov_2','wind_speed') }}
    kilometrov za hodinu
  options:
    voice: "sk_SK-lili-medium"
  media_player_entity_id: media_player.sonos_roam
  cache: true
target:
  entity_id: tts.piper

I would like this to work to, but it fails. :frowning: