Not Sure How to Fix When Text To Speech First Time it misses part of Word

so i have node red automation when an incoming calls come in it will say

“Joe Blow Is Calling” and repeats this for 20 seconds

but what i notice is cuz it does it 7 times usually depending the lenght of the name
it will do

“Joe Blow Is”
“Joe Blow Is Calling”
“Joe Blow Is Calling”
“Joe Blow Is Calling”
“Joe Blow Is Calling”

it glitchs the first time… i not sure if its a Esphome issue, a media player issue a node red issue… so i figured id ask here

here is my jsons and how o do it is

msg.payload = msg.payload.Name + " Is Calling"
return msg;

thats how i do it but it skips the first time running

[{"id":"3a36aafc0827ab96","type":"api-call-service","z":"dbde2ad1b4af7ed2","name":"Text-To-Speech To Devices","server":"915baa48.9b1898","version":7,"debugenabled":false,"action":"tts.speak","floorId":[],"areaId":[],"deviceId":[],"entityId":["tts.piper"],"labelId":[],"data":"{           \"message\": msg.payload, \t            \"media_player_entity_id\": [\t            \"media_player.speaker_1_esphome_i2s_media_player\"\t            \t            ]\t}\t","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"tts","service":"speak","output_location":"","output_location_type":"none","x":980,"y":3060,"wires":[[]]},{"id":"9cf490344d72b724","type":"api-call-service","z":"dbde2ad1b4af7ed2","name":"Set Volume 100%","server":"915baa48.9b1898","version":7,"debugenabled":false,"action":"media_player.volume_set","floorId":[],"areaId":[],"deviceId":[],"entityId":["media_player.speaker_1_esphome_i2s_media_player","media_player.speaker_2_esphome_i2s_media_player","media_player.speaker_3_esphome_i2s_media_player"],"labelId":[],"data":"{\"volume_level\":1}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"media_player","service":"volume_set","output_location":"","output_location_type":"none","x":730,"y":3060,"wires":[["3a36aafc0827ab96"]]},{"id":"74da379225a01243","type":"trigger","z":"dbde2ad1b4af7ed2","name":"Repeat Calling Message","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-3","extend":false,"overrideDelay":false,"units":"s","reset":"stop","bytopic":"all","topic":"topic","outputs":1,"x":410,"y":3020,"wires":[["9cf490344d72b724"]]},{"id":"16c98567b818f293","type":"function","z":"dbde2ad1b4af7ed2","name":"Is Calling","func":"msg.payload = msg.payload.Name + \" Is Calling\"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":140,"y":3020,"wires":[["74da379225a01243"]]},{"id":"691a61569537825f","type":"change","z":"dbde2ad1b4af7ed2","name":"Send Stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":3080,"wires":[["74da379225a01243","642338fa6fcf6853"]]},{"id":"642338fa6fcf6853","type":"api-call-service","z":"dbde2ad1b4af7ed2","name":"Kill Audio Alarm","server":"915baa48.9b1898","version":7,"debugenabled":false,"action":"media_player.media_stop","floorId":[],"areaId":[],"deviceId":[],"entityId":["media_player.speaker_1_esphome_i2s_media_player","media_player.speaker_2_esphome_i2s_media_player","media_player.speaker_3_esphome_i2s_media_player"],"labelId":[],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"media_player","service":"media_stop","output_location":"","output_location_type":"none","x":380,"y":3060,"wires":[[]]},{"id":"7512a166598a9505","type":"inject","z":"dbde2ad1b4af7ed2","name":"","props":[{"p":"payload.Name","v":"Joe Blow","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":2880,"wires":[["16c98567b818f293"]]},{"id":"03ea0b86776f741f","type":"inject","z":"dbde2ad1b4af7ed2","name":"","props":[{"p":"payload"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"stop","payloadType":"str","x":130,"y":3200,"wires":[["691a61569537825f"]]},{"id":"915baa48.9b1898","type":"server","name":"Home Assistant","version":6,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":["y","yes","true","on","home","open"],"connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"c365acd9ba389573","type":"global-config","env":[],"modules":{"node-red-contrib-home-assistant-websocket":"0.80.3"}}]

and im guessing it probably glitchs audio files when it first plays i not sure i onyl test with an alarm if there is a fire or water flooding

i test in home assistant as a script no issues… it has “cache” set to true… so i added that to the call service… as its not one of the examples it says at the bottom… but it didnt help still cuts off “calling” the first time

How long of a delay do you have between announcements? My first assumption would be that it takes longer the first time since it’s having to actually create the TTS audio file versus just pulling it from the cache subsequent times.

in node red its a 3 second resend for that loop… in home assistant script not delay and it also messes up the end the first time

and the delay i use is 20 seconds so after 20 seconds it sends the stop

so this HA script

sequence:
  - action: media_player.volume_set
    metadata: {}
    target:
      device_id: c27cc10926690ae05473ccd12b2c8756
    data:
      volume_level: 0.73
  - action: tts.speak
    metadata: {}
    target:
      entity_id: tts.piper
    data:
      cache: false
      media_player_entity_id: media_player.speaker_1_esphome_i2s_media_player
      message: hello this is a test 1 2 3 4 joe moo
alias: "!! Speaker #1 Test (Duplicate)"
description: ""

will also messed up and not play the moo till the second time… ive tried the cache true and false… if you change the words… it will sometimes work fine other times it cuts off the last word

ever since esphome decommished a working media player and went to a new coding… its been a cluster f at times

That seems really short. Have you tried significantly longer to see if it makes a difference?

no havent tried i can try… also that HA script above fails too… ever since they changed how media player works its buggered up not sure how to re code the esphome media player

here is the esphome code

i2s_audio:
  i2s_lrclk_pin: GPIO16
  i2s_bclk_pin: GPIO21
speaker:
  - platform: i2s_audio
    id: speaker_id
    dac_type: external
    i2s_dout_pin: GPIO17
    sample_rate: 22050 #48000
media_player:
  - platform: speaker
    name: "ESPHome I2S Media Player"
    id: speaker_media_player_id
    announcement_pipeline:
      speaker: speaker_id
      num_channels: 1
      format: WAV
    codec_support_enabled: false
    buffer_size: 4000

so changing to 5 seconds didnt help or 10 seconds on the repeat
as soon as you change a word it cuts the last word off untill it repeats and then it plays properly…

same with the script it fails till u run it a 2nd time