TTS language

Long story short.
I have had issues with TTS for some time now, and instead of trying to fix it I figured I could buy a solution (Nabu casa).
So created an account and after some time I got the Cloud TTS working, great…

But when I go to my media players and use the TTS from there something is wrong.

I used to have:

 tts:
   - platform: google_translate
     language: 'sv'
     base_url: https://foobar.duckdns.org:8123

and replaced it with:

tts:
  - platform: google_translate
    language: 'sv'
    base_url: http://192.168.1.147:8123

But she speaks English…
I have tried lots of different ways but either it doesn’t work at all or it’s in English.
I can’t get the cloud TTS working at all as “default TTS” (perhaps that shouldn’t work).

Any suggestions what I could try?

I’ve exact the same problem, I want the language set to Dutch but not working.
When I create an automation:

  - service: tts.cloud_say
    data:
      language: nl-NL
      message: Hallo, bericht..
      entity_id: media_player.living_room_mini

It works fine in Dutch but not when I go to my media players and use the TTS from there.

I have created a workaround.
It’s not a very elegant solution but it works fine.

A simple entities card with a footer button.
image

And using Node red to control it.

All you need to do is create three helpers.
input_text.google_say // the message (mdi:google-home)
input_select.google_say_dropdown // the devices/rooms it can be played in (mdi:google-home)
input_boolean.google_say_send // the footer button (mdi:send)

Card yaml:

type: entities
entities:
  - entity: input_text.google_say
    name: ' Meddelande'
  - entity: input_select.google_say_dropdown
    name: Skicka meddelande till
footer:
  type: buttons
  entities:
    - entity: input_boolean.google_say_send

Node red flow:

[{"id":"d1f8c4d4.0fb728","type":"tab","label":"Google say","disabled":false,"info":""},{"id":"1d76ebe2.2818e4","type":"trigger-state","z":"d1f8c4d4.0fb728","name":"Trigger on button click","server":"4bbca37b.1700ec","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.google_say_send","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"3blmfnlex52","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":150,"y":240,"wires":[["f723e3ec.4320d"],[]]},{"id":"f723e3ec.4320d","type":"api-current-state","z":"d1f8c4d4.0fb728","name":"Get message","server":"4bbca37b.1700ec","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_text.google_say","state_type":"str","state_location":"message","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":350,"y":240,"wires":[["39ac6f3c.6171"]]},{"id":"39ac6f3c.6171","type":"api-current-state","z":"d1f8c4d4.0fb728","name":"Get device/room","server":"4bbca37b.1700ec","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_select.google_say_dropdown","state_type":"str","state_location":"room","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":640,"y":240,"wires":[["b16fb48d.45e978"]]},{"id":"b16fb48d.45e978","type":"function","z":"d1f8c4d4.0fb728","name":"\"Translate\" room to media_player","func":"if(msg.room == \"Vardagsrum\"){\n    msg.device = \"media_player.vardagsrum_mini\";\n    \n}else if(msg.room == \"Köket\"){\n    msg.device = \"media_player.kok_mini\";\n    \n}else if(msg.room == \"Davids rum\"){\n    msg.device = \"media_player.david_mini\";\n    \n}else if(msg.room == \"Sovrum\"){\n    msg.device = \"media_player.sovrum_mini\";\n    \n}else if(msg.room == \"Nedervåningen\"){\n    msg.device = \"media_player.nedervaningen\";\n    \n}else if(msg.room == \"Ovanvåningen\"){\n    msg.device = \"media_player.ovanvaningen\";\n    \n}else if(msg.room == \"Alla\"){\n    msg.device = \"media_player.hela_huset\";\n    \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":900,"y":240,"wires":[["aacef671.3a3e38"]]},{"id":"aacef671.3a3e38","type":"function","z":"d1f8c4d4.0fb728","name":"Build message to speak json string","func":"\nmsg.payload = {\n    data:{\n        \"entity_id\": msg.device,\n        \"message\": msg.message,\n        \"language\": \"sv-SE\"\n    }\n}\n\n\nmsg.topic = \"\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1220,"y":240,"wires":[["10226b7b.97b925","c96e8922.99be78"]]},{"id":"10226b7b.97b925","type":"api-call-service","z":"d1f8c4d4.0fb728","name":"Speak message","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"tts","service":"cloud_say","entityId":"media_player.nedervaningen","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1500,"y":240,"wires":[[]]},{"id":"51e0b57.77c5a4c","type":"api-call-service","z":"d1f8c4d4.0fb728","name":"Turn off boolean","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.google_say_send","data":"{\"entity_id\":\"input_boolean.google_say_send\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1820,"y":140,"wires":[["bab91909.b967c8"]]},{"id":"bab91909.b967c8","type":"api-call-service","z":"d1f8c4d4.0fb728","name":"Reset text","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"input_text","service":"set_value","entityId":"input_text.google_say","data":"{\"entity_id\":\"input_text.google_say\",\"value\":\"Skriv meddelande\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2080,"y":140,"wires":[["736e9bee.f074b4"]]},{"id":"736e9bee.f074b4","type":"api-call-service","z":"d1f8c4d4.0fb728","name":"Reset select","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.google_say_dropdown","data":"{\"entity_id\":\"input_select.google_say_dropdown\",\"option\":\"Vardagsrum\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2370,"y":140,"wires":[[]]},{"id":"15ba1082.8b79ef","type":"function","z":"d1f8c4d4.0fb728","name":"Empty message","func":"\nmsg.payload = \"\";\nmsg.event_type = \"\";\nmsg.topic = \"\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1640,"y":140,"wires":[["51e0b57.77c5a4c"]]},{"id":"c96e8922.99be78","type":"delay","z":"d1f8c4d4.0fb728","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1480,"y":140,"wires":[["15ba1082.8b79ef"]]},{"id":"4bbca37b.1700ec","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

The flow needs some tinkering to be set up for your enviroment.

I’ve made also a workarround:
configuration.yaml:

input_text:
  tts_syntesiser:
    name: TTS2Google

Script:

tts:
  alias: TTS
  sequence:
  - service: tts.cloud_say
    data:
      language: nl-NL
      message: '{{ states(''input_text.tts_syntesiser'') }}"'
      entity_id: media_player.googlehome8966

Lovelace button:

type: entities
entities:
  - entity: input_text.tts_syntesiser
    name: Typ hier de tekst in
  - entity: script.tts
    name: Naar zolder
    icon: 'mdi:music'
    tap_action:
      action: toggle

Works fine, i’ve made 3 scripts for 3 media players.
TTS-1

1 Like

Tried this script but it doesn’t allow me to change the text, it just says “unknown” in greyed text.

Did you create the input_text? It sounds like you forgot to do that.

Didn’t try your example since i haven’t tried Node yet. But i will get started soon. :slight_smile:

Managed to get the script from @Evert-Jan_van_Laar going, just had to ad

initial: ''

in the configuration.yaml under the input_text.

Tried this solution now with no success.

“Call-service API error. Error Message: Service not found.”

Is the only result i get, tried using it with base_url under the tts with both http://myip:8123, http://myip, https://myip:8123, https://myip, http://domain.duckdns.org, https://domain.duckdns.org
All possible combinations

When i try using the default mediaplayer card everything works as expected (it’s in english however)?

Any ideas?

Where do you get this error?

Never mind, im totaly stupid… :grin:
Found out that i had named my tts service to something else. It only took me a couple of hours. :unamused:

I’m using ReversoTTS (GitHub - rt400/ReversoTTS-HA: ReversoTTS component for HomeAssistant) works great with a TTS notification automation, script and my speakers now

I also created a simple thing to send message with different TTS services (Reverso, Nabu Casa) this way I can use different languages son loves that and learns from it :wink: