Chime TTS - Play audio before/after TTS audio lag free

The behavior is now inconsistent and unpredictable on v1.1.4-beta3. With cache: true it works sometimes, but other times it will only play on the Sonos speakers and not on the Alexa speakers at all, or the message may play on the Alexa speakers but several minutes after the service was called. Other times I get the Simon Says error message. No difference in the YAML.

2024-07-05 08:12:23.618 DEBUG (MainThread) [custom_components.chime_tts] *** Pre-Playback Actions ***
2024-07-05 08:12:23.618 DEBUG (MainThread) [custom_components.chime_tts] ****************************
2024-07-05 08:12:23.618 DEBUG (MainThread) [custom_components.chime_tts] **************************
2024-07-05 08:12:23.618 DEBUG (MainThread) [custom_components.chime_tts] *** Chime TTS playback ***
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] **************************
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] 1 Sonos media player detected:
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] - media_player.basement_bedroom
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] 1 Alexa media player detected:
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] - media_player.michael_s_2nd_echo_dot
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media with data:
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.basement_bedroom']
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] - announce: False
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2024-07-05 08:12:23.619 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/kquxm20n.mp3
2024-07-05 08:12:23.622 DEBUG (MainThread) [custom_components.chime_tts] Calling notify.alexa_media with data:
2024-07-05 08:12:23.623 DEBUG (MainThread) [custom_components.chime_tts] - message: <audio src="https://hidden.site//local/chime_tts/16uh9wjf.mp3"/>
2024-07-05 08:12:23.623 DEBUG (MainThread) [custom_components.chime_tts] - data: {'type': 'tts'}
2024-07-05 08:12:23.629 DEBUG (MainThread) [custom_components.chime_tts] - target: ['media_player.michael_s_2nd_echo_dot']
2024-07-05 08:12:23.630 DEBUG (MainThread) [custom_components.chime_tts] - Waiting 3.672s for audio playback to complete...
2024-07-05 08:12:27.305 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] - Waiting until 2 media_players aren't playing...
2024-07-05 08:12:27.305 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.michael_s_2nd_echo_dot
2024-07-05 08:12:27.910 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.basement_bedroom
2024-07-05 08:12:27.911 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 4.88 s -----
2024-07-05 08:12:57.456 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v1.1.4-beta3 -----
2024-07-05 08:12:57.457 DEBUG (MainThread) [custom_components.chime_tts.queue_manager] Adding service call to queue
2024-07-05 08:12:57.459 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ----- General Parameters -----
2024-07-05 08:12:57.460 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * entity_ids:
2024-07-05 08:12:57.460 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 0: media_player.michael_s_echo
2024-07-05 08:12:57.460 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 1: media_player.michael_s_4th_echo_dot
2024-07-05 08:12:57.460 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 2: media_player.basement_bedroom
2024-07-05 08:12:57.460 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 3: media_player.michael_s_echo_dot
2024-07-05 08:12:57.461 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 4: media_player.michael_s_3rd_echo_dot
2024-07-05 08:12:57.461 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 5: media_player.michael_s_2nd_echo_dot
2024-07-05 08:12:57.461 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 6: media_player.kids_bedroom
2024-07-05 08:12:57.461 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * chime_path = /config/www/custom_audio/Alexa_Notification.mp3
2024-07-05 08:12:57.461 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * cache = True
2024-07-05 08:12:57.461 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * offset = 450.0
2024-07-05 08:12:57.462 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * final_delay = 0.0
2024-07-05 08:12:57.462 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * message = It's time to take out the trash
2024-07-05 08:12:57.462 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * tts_speed = 100.0
2024-07-05 08:12:57.462 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * tts_pitch = 0
2024-07-05 08:12:57.463 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * announce = False
2024-07-05 08:12:57.464 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * fade_audio = False
2024-07-05 08:12:57.464 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * volume_level = -1
2024-07-05 08:12:57.464 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * join_players = False
2024-07-05 08:12:57.464 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * unjoin_players = False
2024-07-05 08:12:57.464 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * audio_conversion = -y -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 -write_xing 0
2024-07-05 08:12:57.465 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * media_players_array:
2024-07-05 08:12:57.465 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 0: entity_id: media_player.michael_s_echo
2024-07-05 08:12:57.465 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] platform: alexa_media
2024-07-05 08:12:57.465 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] initial volume: 0.3
2024-07-05 08:12:57.465 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] target volume: -1.0
2024-07-05 08:12:57.465 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] now playing: False
2024-07-05 08:12:57.466 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join supported: False
2024-07-05 08:12:57.466 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce supported: False
2024-07-05 08:12:57.466 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 1: entity_id: media_player.michael_s_4th_echo_dot
2024-07-05 08:12:57.466 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] platform: alexa_media
2024-07-05 08:12:57.466 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] initial volume: 0.23
2024-07-05 08:12:57.466 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] target volume: -1.0
2024-07-05 08:12:57.467 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] now playing: False
2024-07-05 08:12:57.467 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join supported: False
2024-07-05 08:12:57.467 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce supported: False
2024-07-05 08:12:57.467 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 2: entity_id: media_player.basement_bedroom
2024-07-05 08:12:57.467 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] platform: sonos
2024-07-05 08:12:57.467 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] initial volume: 0.17
2024-07-05 08:12:57.467 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] target volume: -1.0
2024-07-05 08:12:57.468 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] now playing: False
2024-07-05 08:12:57.468 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join supported: True
2024-07-05 08:12:57.468 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce supported: True
2024-07-05 08:12:57.468 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 3: entity_id: media_player.michael_s_echo_dot
2024-07-05 08:12:57.468 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] platform: alexa_media
2024-07-05 08:12:57.468 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] initial volume: -1.0
2024-07-05 08:12:57.468 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] target volume: -1.0
2024-07-05 08:12:57.468 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] now playing: False
2024-07-05 08:12:57.469 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join supported: False
2024-07-05 08:12:57.469 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce supported: False
2024-07-05 08:12:57.469 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 4: entity_id: media_player.michael_s_3rd_echo_dot
2024-07-05 08:12:57.470 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] platform: alexa_media
2024-07-05 08:12:57.470 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] initial volume: 0.27
2024-07-05 08:12:57.470 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] target volume: -1.0
2024-07-05 08:12:57.470 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] now playing: False
2024-07-05 08:12:57.470 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join supported: False
2024-07-05 08:12:57.470 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce supported: False
2024-07-05 08:12:57.470 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 5: entity_id: media_player.michael_s_2nd_echo_dot
2024-07-05 08:12:57.470 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] platform: alexa_media
2024-07-05 08:12:57.472 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] initial volume: -1.0
2024-07-05 08:12:57.472 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] target volume: -1.0
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] now playing: False
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join supported: False
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce supported: False
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 6: entity_id: media_player.kids_bedroom
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] platform: sonos
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] initial volume: 0.21
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] target volume: -1.0
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] now playing: False
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join supported: True
2024-07-05 08:12:57.473 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce supported: True
2024-07-05 08:12:57.474 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] --- Audio will be converted to Alexa-friendly format as Alexa speaker/s detected ---
2024-07-05 08:12:57.474 DEBUG (MainThread) [custom_components.chime_tts] *** Checking Chime TTS audio cache ***
2024-07-05 08:12:57.556 DEBUG (MainThread) [custom_components.chime_tts] Cached audio found:
2024-07-05 08:12:57.556 DEBUG (MainThread) [custom_components.chime_tts] - public_path = "https://hidden.site//local/chime_tts/v0ocqf0i.mp3"
2024-07-05 08:12:57.556 DEBUG (MainThread) [custom_components.chime_tts] - audio_duration = 4.584
2024-07-05 08:12:57.556 DEBUG (MainThread) [custom_components.chime_tts] - local_path = "/media/sounds/temp/chime_tts/v0ocqf0i.mp3"
2024-07-05 08:12:57.556 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id = "media-source://media_source/local/sounds/temp/chime_tts/v0ocqf0i.mp3"
2024-07-05 08:12:57.556 DEBUG (MainThread) [custom_components.chime_tts] Apply audio conversion
2024-07-05 08:12:57.558 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] Converting audio: "ffmpeg -i /media/sounds/temp/chime_tts/v0ocqf0i.mp3 -y -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 -write_xing 0 /media/sounds/temp/chime_tts/v0ocqf0i_converted.mp3"
2024-07-05 08:12:57.827 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] Converting audio: "ffmpeg -i /config/www/chime_tts/v0ocqf0i.mp3 -y -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 -write_xing 0 /config/www/chime_tts/v0ocqf0i_converted.mp3"
2024-07-05 08:12:58.081 DEBUG (MainThread) [custom_components.chime_tts] ...cached audio found
2024-07-05 08:12:58.081 DEBUG (MainThread) [custom_components.chime_tts] ****************************
2024-07-05 08:12:58.082 DEBUG (MainThread) [custom_components.chime_tts] *** Pre-Playback Actions ***
2024-07-05 08:12:58.082 DEBUG (MainThread) [custom_components.chime_tts] ****************************
2024-07-05 08:12:58.082 DEBUG (MainThread) [custom_components.chime_tts] **************************
2024-07-05 08:12:58.082 DEBUG (MainThread) [custom_components.chime_tts] *** Chime TTS playback ***
2024-07-05 08:12:58.082 DEBUG (MainThread) [custom_components.chime_tts] **************************
2024-07-05 08:12:58.082 DEBUG (MainThread) [custom_components.chime_tts] 2 Sonos media players detected:
2024-07-05 08:12:58.082 DEBUG (MainThread) [custom_components.chime_tts] - media_player.basement_bedroom
2024-07-05 08:12:58.082 DEBUG (MainThread) [custom_components.chime_tts] - media_player.kids_bedroom
2024-07-05 08:12:58.083 DEBUG (MainThread) [custom_components.chime_tts] 5 Alexa media players detected:
2024-07-05 08:12:58.083 DEBUG (MainThread) [custom_components.chime_tts] - media_player.michael_s_echo
2024-07-05 08:12:58.083 DEBUG (MainThread) [custom_components.chime_tts] - media_player.michael_s_4th_echo_dot
2024-07-05 08:12:58.083 DEBUG (MainThread) [custom_components.chime_tts] - media_player.michael_s_echo_dot
2024-07-05 08:12:58.083 DEBUG (MainThread) [custom_components.chime_tts] - media_player.michael_s_3rd_echo_dot
2024-07-05 08:12:58.083 DEBUG (MainThread) [custom_components.chime_tts] - media_player.michael_s_2nd_echo_dot
2024-07-05 08:12:58.083 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media with data:
2024-07-05 08:12:58.083 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.basement_bedroom', 'media_player.kids_bedroom']
2024-07-05 08:12:58.084 DEBUG (MainThread) [custom_components.chime_tts] - announce: False
2024-07-05 08:12:58.084 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2024-07-05 08:12:58.084 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/v0ocqf0i.mp3
2024-07-05 08:12:58.085 DEBUG (MainThread) [custom_components.chime_tts] Calling notify.alexa_media with data:
2024-07-05 08:12:58.085 DEBUG (MainThread) [custom_components.chime_tts] - message: <audio src="https://hidden.site//local/chime_tts/v0ocqf0i.mp3"/>
2024-07-05 08:12:58.085 DEBUG (MainThread) [custom_components.chime_tts] - data: {'type': 'tts'}
2024-07-05 08:12:58.085 DEBUG (MainThread) [custom_components.chime_tts] - target: ['media_player.michael_s_echo', 'media_player.michael_s_4th_echo_dot', 'media_player.michael_s_echo_dot', 'media_player.michael_s_3rd_echo_dot', 'media_player.michael_s_2nd_echo_dot']
2024-07-05 08:12:58.088 DEBUG (MainThread) [custom_components.chime_tts] - Waiting 4.584s for audio playback to complete...
2024-07-05 08:13:02.679 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] - Waiting until 7 media_players aren't playing...
2024-07-05 08:13:02.680 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.michael_s_echo
2024-07-05 08:13:02.680 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.michael_s_4th_echo_dot
2024-07-05 08:13:02.680 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.michael_s_echo_dot
2024-07-05 08:13:02.680 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.michael_s_3rd_echo_dot
2024-07-05 08:13:02.681 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.michael_s_2nd_echo_dot
2024-07-05 08:13:03.292 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.basement_bedroom
2024-07-05 08:13:03.497 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] āœ” media_player.kids_bedroom
2024-07-05 08:13:03.498 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 6.04 s -----```

Hi @msl2424 iā€™m sorry youā€™re still having issues.

Unfortunately I donā€™t see any clues in the debug log messages as everything looks correct.

Is there anything else you can share that might shed some light on the what might be going on? For example: does the issue occur immediately after a hard restart, or only after 5+ calls to to Chime TTS?

Hereā€™s what Iā€™ve found. When I test in Developer Tools > Services using Chime TTS: Say targeting multiple Sonos and Alexa (Echo) speakers, it works if I set cache: true. For each of these tests, the message I used was This is a test. I then went to implement the exact same code in my automations, but it failed on the Echo speakers, returning the Simon Says error message. The only thing different in my automations is the message, for example, saying Its time to take out the trash instead of This is a test. If I changed the message in the automation to This is a test then it worked, but not if I used any other text. Is this a cache issue? Any ideas?

Iā€™m using both Alexa and Sonos and havenā€™t had any issues with one or the other, in your automations are you using the Audio Conversion parameter? Alexas are sensitive to the format of the audio file and will give the Simon Says error if itā€™s wrong.
My thought is that when using the ā€œthis is a testā€ message the audio file was already created with the conversion, where the ā€œtrashā€ message was not and therefore was failing.

Chime TTS knows to format the audio for Alexa speakers automatically, so I donā€™t think thatā€™s the issue.

@msl2424 succeeded to make service calls to chime_tts.say from both the ā€œServicesā€ tab and from a script, so it seems unlikely that thereā€™s an issue there either. The issue occurs when a non-cached message is generated, whereas cached notifications are played correctly.

My guess is that the public folder path set in the Chime TTS configuration may have recently been changed to one not publicly accessible.

I have not made any change to the Chime TTS configuration since I first set it up. Or are you saying this may be something you need to change in the backend? Thanks for going back and forth with me on this.

Thanks for the suggestion, but I had also tested the Audio Conversion parameter and it did not make a difference. Would you please share the YAML for an announcement you are using that plays on both Alexa and Sonos devices at the same time?

Iā€™m not sure yet where the issue lies.

Do you hear the notification on your Alexas if you call chime_tts.say with cache: true and the message parameter set to a new string (that does not exist in the cache)?

Yep, I can duplicate the condition - I hadnā€™t been trying both devices simultaneously since they were in close proximity, but when doing both I get the Simon Says error on the Alexa .

Found this error in my log:

2024-07-08 07:44:06.454 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to scandir with args ('/config/www',) inside the event loop by custom integration 'chime_tts' at custom_components/chime_tts/helpers/filesystem.py, line 279: for root, _, files in os.walk(directory): (offender: <frozen os>, line 366: ?), please create a bug report at https://github.com/nimroddolev/chime_tts/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#scandir
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/config/custom_components/chime_tts/queue_manager.py", line 38, in async_process_queue
    result = await asyncio.wait_for(
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
  File "/config/custom_components/chime_tts/__init__.py", line 182, in async_say_execute
    return await async_prepare_media(hass, params, options, media_players_array, is_say_url, start_time)
  File "/config/custom_components/chime_tts/__init__.py", line 289, in async_prepare_media
    audio_dict = await async_get_playback_audio_path(params, options)
  File "/config/custom_components/chime_tts/__init__.py", line 792, in async_get_playback_audio_path
    audio_dict[PUBLIC_PATH_KEY] = filesystem_helper.get_external_url(hass, audio_dict.get(PUBLIC_PATH_KEY, None))
  File "/config/custom_components/chime_tts/helpers/filesystem.py", line 296, in get_external_url
    if self.file_exists_in_directory(file_path, public_dir) is False:
  File "/config/custom_components/chime_tts/helpers/filesystem.py", line 279, in file_exists_in_directory
    for root, _, files in os.walk(directory):

Updated testing results below. The only thing different among them is the message. Otherwise all have cache: true. Sample YAML below.

Testing

  1. Existing automation with a Chime TTS Say action and the message It's time to take out the trash played successfully on Alexa and Sonos devices.
  2. If I copy and paste the exact same Chime TTS Say action and message in another automation, and it also works. However, if I edit the message to be anything besides This is a test or It's time to take out the trash it does not work.
  3. If I test the Chime TTS Say service in Developer Tools, I can input any message Iā€™d like and it works when sent to only an Alexa device or only a Sonos device. If I send to both an Alexa and a Sonos device at the same time, it works if the message is This is a test or It's time to take out the trash. If I change to another random message such as Hello world then it only works on the Sonos speaker whereas the Alexa speaker gives the Simon Says error, and curiously the volume is much louder/better on both the Sonos and Alexa speakers in this scenario when it works on the Sonos but fails on the Alexa. When it works on both devices, the volume too quiet.

YAML that works on both Sonos and Alexa

service: chime_tts.say
data:
  message: This is a test
  chime_path: /config/www/custom_audio/Alexa_Notification.mp3
  cache: true
target:
  entity_id:
    - media_player.michael_s_2nd_echo_dot
    - media_player.basement_bedroom

YAML that works on Sonos but not Alexa

service: chime_tts.say
data:
  message: Hello world
  chime_path: /config/www/custom_audio/Alexa_Notification.mp3
  cache: true
target:
  entity_id:
    - media_player.michael_s_2nd_echo_dot
    - media_player.basement_bedroom

Hi @msl2424. I have released a new beta version, v1.1.4-beta4, which includes (among other additions) simplification and refactoring of a lot of the code responsible for caching MP3 files.

I think it may have addressed the issue of playing to both Sonos and Alexas in the same service call to chime_tts.say. Can you please upgrade to the new version and let me know if the issue is resolved?

Hi @Nimrod_Dolev. I updated to v1.1.4-beta4, and the issues remain. It continues to only work on both the Sonos and Alexa device in a single service call when I use the message This is a test or It's time to take out the trash. Any other message fails on the Alexa device with the Simon Says error. At first I could play any message on just the Alexa device, but after the getting the first Simon Says error when sending to both device types, I could no longer send a message to only Alexa other than This is a test or It's time to take out the trash. The volume is also super quiet on both devices when playing This is a test but louder when playing It's time to take out the trash.

Hi @msl2424, for troubleshooting curiousity, are you able to play another string directly to Alexa using the Alexa media service without issue? An example below you can run under Services in Developer Tools:

service: notify.alexa_media
data:
  message: Someone's At The Door Michael!
  target:
    - media_player.michael_s_2nd_echo_dot
  data:
    type: tts
enabled: true

Hi @ColtonYYZ, yes, the YAML you shared works without issue no matter the message that I use. Message plays correctly, and the volume level is normal.

Good morning everyone, i use chime tts on home assistant, everything goes very well until at some point even forcing the various scripts where i start the tts over the mp3 stored locally the whole thing stops. i installed the beta version hoping this would fix the problem but nothing. everything works until after n times it stops working. i attach the logs this way you tell me what you think. i think that when he wants to start and finds the media. player stay inactive it puts the task in the queue and does nothing elseā€¦ from there on all scripts will go in the queue. i tried using clear cache but nothing changes, the only way to restart it is to restart HA which is probably equivalent to clearing the queue. is there a command i could use before fixing the queue? or just make it so that if it finds unknown the mediaplayer status it forces the volume for how i put the script in. below i also put the script example

service: chime_tts.say
target:
  device_id:
    - 390a59438e130f9ca39bf2d7b654bb7c
data:
  message: Sono le tredici e trenta minuti, sto chiudendo le tende dell open Space
  volume_level: 0.5
  chime_path: /config/www/musica/IronMan_backinblack_cut_11s.mp3
  offset: -10000
  tts_speed: 110

Can you please share the debug logs for the service call that failed to complete/be removed from the queue?

Im getting a timeout if the message is longer than 60 seconds. How can I fix it?
The message plays completely, but the automation stops there.

Service call timed out after 60.0s (configured timeout = 60s)

Hi,

I have problems with the volume settings of my Sonos speakers. I tried with the official release and with the latest beta v1.1.4-beta4. I tried to set it in Yaml and with the UI, but both are not changing the volume of my Sonos speakers. When I check announce the volume setting is taken into account but without it is not workingā€¦ But is want the music completely silent when saying the message, so using announce is not an option.
Any advice?

Cheers
Kris

Hi @Rich37804. You can change the timeout duration in the integrationā€™s configuraiton page

So obviousā€¦Thanks!