I use Google Cloud as my text to speech service in Home Assistant. Everything works fine calling the service within an automation/script. However these TTS messages have grown in size quite a bit over time and I would like to move the message to a yaml file that the TTS can read from.
I have seen some videos online where in the message section of the TTS service they use ‘!include path/to/yaml/file.yaml’. But any time I enter this in an automation/script either via the front end or in yaml, Google always just reads the message as is ( example “!include path/to/yaml/file.yaml”) instead of the content that is in the yaml file.
Where am I going wrong with this? Is there something I need to input into my configuration.yaml file or how can I get the TTS service to read from a yaml file instead of having to put the message directly in the automation/script?
Thanks for that link. It pointed me in the right direction and I finally got it working.
It seems a bit counterintuitive to set a variable with the TTS message first but seems to work. Now to test with a longer message and hopefully it still work. Not sure how many characters you can store in the variable so hopefully it doesn’t fall over with longer messages.
For anyone looking at this in the future don’t include the in the message part of the TTS service but do include it in the yaml file otherwise it won’t work. This only applies if you are using Google Cloud Say and not the regular TTS service from Google.
Hi @unknowndarkmatterpie
Having the same troubles here with getting the path spoken instead of the file content I’m pointing to. Would you mind to post your service call and your yaml-file content?
Sure, what I did was create a script and in the sequence I would first define a variable which would grab the TTS message from a yaml file (using the !include path) and then next step in the sequence I would call the TTS service and instead of passing it the path the yaml file, I would just pass it the variable.
Example below:
sequence:
- variables:
announcement: !include /config/text_to_speech/welcome_home.yaml # path to your yaml file which contains the TTS message
- service: tts.google_cloud_say
data:
cache: false
entity_id: media_player.googlehomemini
options:
text_type: ssml
message: "{{ announcement }}"
Thank you @unknowndarkmatterpie for that. For some reason when I copy your sequence posted the script editor does not accept the announcement variable. Any hint for that?