How can I call tts.speak service with tts.piper?

The error I got


I also tried en-us and en-us-amy-low. None of them work.

try this :point_down:

service: tts.speak
data:
  media_player_entity_id: media_player.your_media_player_with_a_very_long_name_come_here
  message: I am so cute
target:
  entity_id: tts.piper

:speaking_head: :speech_balloon:

This works for English. How can I use another language?

Set your voice and language in the Piper addon configuration.

It doesn’t work. It still uses English.

Works fine here. Did you click save and restart the addon after changing the language?

Did you use a different language for the message parameter?

eg:
message: "Bonjour! Comment ça va ?"

Then choose a existing language you would like to use :point_down:

service: tts.speak
data:
  media_player_entity_id: media_player.your_media_player_with_a_very_long_name_come_here
  language: whateverexists
  message: I am so cute
target:
  entity_id: tts.piper

Yes and Yes. Have you updated to the latest version of HA? 2023.10.0

I don’t know which language code I should use for each language. I have updated my original post to show the error.

You also set the voice - check the piper add-on for the exact codes like shown in the screenshot from @jazzyisj

Yes. Piper is working fine, but I’ve also never specified the language in the service call. I just set the voice in the addon configuration. I did try to set the language to both “en” and “english” using a dev tools service call and got errors.

Have you tried just not setting the language parameter?

That’s why I posted this post, I’ve already checked this and tried en, en-us, and en-us-amy-low.
image

How would I use that in the basic Hass configuration, so I can use it for notifiers, etc.

I now have this in there:

# Text to speech
tts:
  - platform: google_translate
    language: "nl"
1 Like

Not sure if this is helpful or not but I found this thread while trying to figure out how to use tts.speak with Piper in an automation. I also select from multiple languages at random in a single automation.

Note that I am not passing a language value to the service. Selecting the voice (which includes the language already) is enough for it to work without selecting a language. In my example I use two voices:

  • zh_CN-huayan-medium | Chinese (Simplified) medium quality voice
  • en_GB-alan-low | British English low quality voice

The tts message is included in an array with the voice code and then one of these arrays is selected at random and played.

alias: Brush Teeth announcement
  description: ""
  variables:
    message: "{{ [
      ['请注意。你应该去刷牙。', 'zh_CN-huayan-medium'],
      ['男孩们,你需要去刷牙。马上!', 'zh_CN-huayan-medium'],
      ['10 位牙医中有 10 位建议刷牙和使用牙线。现在是你刷牙的时候了!', 'zh_CN-huayan-medium'],
      ['Boys, it is time to brush teeth. Please get to it.', 'en_GB-alan-low' ],
      ['It is time to brush your teeth. You dont want to have bad breath, do you?', 'en_GB-alan-low' ],
      ['Boys, please stop what you are doing and go brush your teeth now. Thank you.', 'en_GB-alan-low' ]
      ]
      | random }}"
  trigger:
    - platform: time
      at: "19:05:00"
  action:
    - service: tts.speak
      entity_id: tts.piper
      data:
        media_player_entity_id: media_player.den
        message: "{{ message[0] }}"
        options:
          voice: "{{ message[1] }}"
  mode: single
4 Likes

thank you mate.
here is an easier version: working in 2025


action: tts.speak
metadata: {}
data:
  cache: true
  media_player_entity_id: media_player.vlc_telnet
  message: >-
    The minimum temperature for the Marstek Battery on the Balkony is
    currently     {{
    states('sensor.hame_energy_hmj_2_7cfefewwef2f_temperature_min') }}    
    degrees, which is below 10 degrees. - spoken with piper
  options:
    voice: en-gb-southern_english_female-low
target:
  entity_id: tts.piper

piper as an addon and wyoming protocol in integrations. You can find a list of voice at rhasspy/piper-voices · Hugging Face

here is an example in an automation to talk to two media_players at once.


 - parallel:
            - service: tts.speak
              target:
                entity_id: tts.piper
              data:
                media_player_entity_id: media_player.squeezelite_garden_2
                message: "{{ alert_message }}"
                cache: true
                options:
                  voice: en_US-lessac-medium

            - service: tts.speak
              target:
                entity_id: tts.piper
              data:
                media_player_entity_id: media_player.dublin
                message: "{{ alert_message }}"
                cache: true
                options:
                  voice: en_US-lessac-medium

I also taught chatgpt so you can ask there

do you remember the conversation we had about piper

ChatGPT said:

Yes, I remember our previous conversation about Piper in Home Assistant. Here’s a quick recap of the key points we’ve covered:


:brain: What I Remember:

  • You’re using Piper with the Wyoming Protocol integration in Home Assistant.
  • You wanted to change the voice used by Piper.
  • I initially mentioned doing this via Devices & Services → Integrations, but you correctly pointed out:

“The default voice can be changed in Settings → Add-ons → Piper.”

  • You also confirmed that:

“Piper voices can be selected using the options.voice key, with values like en_US-joe-medium from the Hugging Face repo.”

  • You were using Whisper, OpenWakeWord, and Piper together.