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"

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
1 Like