I am trying to send a sequence of texts to my speaker in 1 automation.
I notices that only the last sentence is said. All previous texts are somehow skipped.
All help is appreciated!
Below the yaml code of the automation
alias: test speaker
description: ""
trigger: []
condition: []
action:
- service: tts.cloud_say
metadata: {}
data:
message: This is the first sentence
entity_id: media_player.esp32speaker1_esp32_speaker_1
cache: true
- service: tts.cloud_say
metadata: {}
data:
cache: true
message: This is the second sentence
entity_id: media_player.esp32speaker1_esp32_speaker_1
mode: single
Then send your message to the Script via an Automation.
eg:
- service: script.tts_queue_kitchen
data:
message: >
"Good morning, the weather forecast for today will be a maximum of {{ states('sensor.morley_temp_max_0') }} a minimum of {{ states('sensor.morley_temp_min_0') }} and it will be {{ states('sensor.morley_extended_text_0') }}"
Since I have set the Script mode to ‘queued’ it will play any new message after the previous, because at the end of the Script it waits for the media player to be idle.
Than you for helping out. I tried using a script and then had sent multiple sequensive sentences to the speaker from an automation, but this also did not work. I also set the script to “queued” but with the same results. However I saw you also check or the speaker is idle. I will try this as soon as i get my hands back on my keyboard
I tried again and added the
“{{ is_state(‘media_player.esp32speaker1_esp32_speaker_1’, ‘idle’) }}”
but still the automation just skippes all commands and just speaks the last (second) sentence.
alias: test speaker
description: ""
trigger: []
condition: []
action:
- service: tts.cloud_say
metadata: {}
data:
message: This is the first sentence
entity_id: media_player.esp32speaker1_esp32_speaker_1
cache: true
- wait_template: "{{ is_state('media_player.esp32speaker1_esp32_speaker_1', 'idle') }}"
continue_on_timeout: true
- service: tts.cloud_say
metadata: {}
data:
cache: true
message: This is the second sentence
entity_id: media_player.esp32speaker1_esp32_speaker_1
mode: single
Thank you for this valuable hint. Chime TTS looks like a very well worked out integration. Congratz. For now, I will start with using the delay of 2 sec and try the Chime TTS later.
Because creating the tts mp3 files is faster than sending them to the speakers and receiving then updated state of playing.
So what happens is that the first tts is sent and then because the state has not changed to playing yet it will send the second message.
You probably can use 1.5 seconds also but it really doesn’t matter, in my home 1 second or less does not work.
Perhaps it’s different for others.