Hello everyone, I’ve recently been working on my own washing machine, dryer and dishwasher automation that uses a script to announce via tts when devices are done and action is required.
I use a large number of random phrases to accomplish this so that I don’t get the same message over and over.
This has had the effect of increasing my scripts.yaml to be well over 300 lines and increasingly difficult to navigate.
What I’m hoping is possible:
create a script for TTS that calls a messages file to get the random phrases.
Here’s another way to do it. I’ve tested it and it works.
Create a file containing the TTS phrases and structure it as a YAML list. For example, assume we have a file called tts_phrases.yaml and it contents are:
Create a variable in your script called phrases (or whatever you want to call it) and point it to the tts_phrases.yaml file using an !include directive. Reference the phrases variable in the tts.cloud_say service call.
Upon saving the script it replaces !include ./tts_phrases.yaml with null. I store manually created scripts (and automations) separate from the ones created by the Script (and Automation) editor.
Refer to the included file’s location correctly.
The path to tts_phrases.yaml is relative to wherever the script resides. If the script is in the same directory as the tts_phrases.yaml file then either of these will work:
yes that works exactly the way I had hoped it would.
Have you ever considered using a placeholder for the phrases? this way only one script would ever be needed. The automation would call the script and pass the variables.