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

Updated HA and ChimeTTS at the same time.
Happy to report that thus far it is all working fantastically.

I have a quick question,

service: chime_tts.say
metadata: {}
data:
  delay: 100
  final_delay: 250
  tts_playback_speed: 100
  volume: 0.9
  message:
    - type: chime
      path: custom_chime_path_1
    - type: tts
      message: "{{ tod }} Andy!"
      cache: true
    - type: delay
      length: 450
    - type: tts
      message: "{{ temperature }}"
      cache: true
    - type: tts
      message: "{{ weather }}"
      cache: true
    - type: tts
      message: The forecast today is
      cache: true
    - type: tts
      message: "{{ forecast }}"
    - type: delay
      length: 500
    - type: tts
      message: "{{ calendar }}"
    - type: delay
      length: 2000
  tts_platform: tts.piper
target:
  entity_id: "{{ media_player }}"

I changed delay:450 to delay:100 because although it is considered to be the starting delay - in the GUI, it seems to be reapplied between segments. For example:

    - type: tts
      message: "{{ temperature }}"
      cache: true
    - type: tts
      message: "{{ weather }}"
      cache: true
    - type: tts
      message: The forecast today is
      cache: true
    - type: tts
      message: "{{ forecast }}"
    - type: delay
      length: 500

The pauses between these files, which have been cached at this point, was a bit irritating, but changing the global delay to 100 has made this much more palatable. Is this intended behaviour? As the docs suggested that value was just a delay before the audio started?

Hereā€™s some logs in case anything pops up, but all I can see is the difference between the audio file with the initial 450ms delay and the second one with the 100ms delay, is clearly more than half a second.

2024-01-06 22:33:59.274 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.11.1-beta2 -----
2024-01-06 22:33:59.274 DEBUG (MainThread) [custom_components.chime_tts] Service call #0 was added to the queue.
2024-01-06 22:33:59.274 DEBUG (MainThread) [custom_components.chime_tts] Executing queued job #0
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] ----- General Parameters -----
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * entity_ids = ['media_player.livingroom_smart_display']
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * chime_path =
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * end_chime_path =
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * cache = False
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * delay = 450.0
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * message = [{'type': 'chime', 'path': 'custom_chime_path_1'}, {'type': 'tts', 'message': 'Good Night Andy!', 'cache': True}, {'type': 'delay', 'length': 450}, {'type': 'tts', 'message': 'It is currently -2 degrees,', 'cache': True}, {'type': 'tts', 'message': 'and Clear.', 'cache': True}, {'type': 'tts', 'message': 'The forecast today is', 'cache': True}, {'type': 'tts', 'message': 'Partly Cloudy with a high of 4 and a low of -2'}, {'type': 'delay', 'length': 500}, {'type': 'tts', 'message': 'You are on cat sitting duty today.'}, {'type': 'delay', 'length': 2000}]
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = tts.piper
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * announce = False
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = -1.0
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * join_players = False
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] * unjoin_players = False
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] ----- TTS-Specific Params -----
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] -------------------------------
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2024-01-06 22:33:59.275 DEBUG (MainThread) [custom_components.chime_tts] Invalid audio filepath provided
2024-01-06 22:33:59.278 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("/media/notify/pa_announce.mp3", 450.0, audio)
2024-01-06 22:33:59.278 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving audio from path: "/media/notify/pa_announce.mp3"...
2024-01-06 22:33:59.422 DEBUG (MainThread) [custom_components.chime_tts] - ...retrieved successfully. Audio duration: 2.438s
2024-01-06 22:33:59.422 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='Good Night Andy!', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:33:59.422 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:33:59.561 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 139.209 ms
2024-01-06 22:33:59.565 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='It is currently -2 degrees,', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:33:59.565 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:33:59.683 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 118.185 ms
2024-01-06 22:33:59.690 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='and Clear.', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:33:59.690 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:33:59.803 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 113.122 ms
2024-01-06 22:33:59.807 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='The forecast today is', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:33:59.807 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:33:59.930 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 123.083 ms
2024-01-06 22:33:59.936 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='Partly Cloudy with a high of 4 and a low of -2', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:33:59.936 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:34:00.069 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 132.715 ms
2024-01-06 22:34:00.079 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='You are on cat sitting duty today.', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:34:00.080 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:34:00.655 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 575.4780000000001 ms
2024-01-06 22:34:00.668 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created. Duration: 20.804s
2024-01-06 22:34:00.668 DEBUG (MainThread) [custom_components.chime_tts] - Saving mp3 file...
2024-01-06 22:34:00.668 DEBUG (MainThread) [custom_components.chime_tts] - Audio folder exists: /media/sounds/temp/chime_tts/
2024-01-06 22:34:01.076 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/media/sounds/temp/chime_tts/y9kwpys0.mp3'
2024-01-06 22:34:01.076 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully
2024-01-06 22:34:01.076 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/media/sounds/temp/chime_tts/y9kwpys0.mp3', 'audio_duration': 20.804}
2024-01-06 22:34:01.076 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:
2024-01-06 22:34:01.076 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2024-01-06 22:34:01.076 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/y9kwpys0.mp3
2024-01-06 22:34:01.077 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.livingroom_smart_display']
2024-01-06 22:34:01.738 DEBUG (MainThread) [custom_components.chime_tts] ...media_player.play_media completed.
2024-01-06 22:34:01.739 DEBUG (MainThread) [custom_components.chime_tts] Waiting 20.804s for audio playback to complete...
2024-01-06 22:34:22.545 DEBUG (MainThread) [custom_components.chime_tts] Waiting 0.25s for final_delay to complete...
2024-01-06 22:34:22.796 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 23521.14 ms -----
2024-01-06 22:34:22.796 DEBUG (MainThread) [custom_components.chime_tts] Removing current queued service call.
2024-01-06 22:34:22.796 DEBUG (MainThread) [custom_components.chime_tts] Queue emptied. Reinitializing values.
2024-01-06 22:35:53.421 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.11.1-beta2 -----
2024-01-06 22:35:53.421 DEBUG (MainThread) [custom_components.chime_tts] Service call #0 was added to the queue.
2024-01-06 22:35:53.421 DEBUG (MainThread) [custom_components.chime_tts] Executing queued job #0
2024-01-06 22:35:53.423 DEBUG (MainThread) [custom_components.chime_tts] ----- General Parameters -----
2024-01-06 22:35:53.423 DEBUG (MainThread) [custom_components.chime_tts] * entity_ids = ['media_player.andylaptop_honor']
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * chime_path =
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * end_chime_path =
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * cache = False
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * delay = 100.0
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * message = [{'type': 'chime', 'path': 'custom_chime_path_1'}, {'type': 'tts', 'message': 'Good Night Andy!', 'cache': True}, {'type': 'delay', 'length': 450}, {'type': 'tts', 'message': 'It is currently -2 degrees,', 'cache': True}, {'type': 'tts', 'message': 'and Clear.', 'cache': True}, {'type': 'tts', 'message': 'The forecast today is', 'cache': True}, {'type': 'tts', 'message': 'Partly Cloudy with a high of 4 and a low of -2'}, {'type': 'delay', 'length': 500}, {'type': 'tts', 'message': 'You are on cat sitting duty today.'}, {'type': 'delay', 'length': 2000}]
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = tts.piper
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * announce = False
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = -1.0
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * join_players = False
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] * unjoin_players = False
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] ----- TTS-Specific Params -----
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] -------------------------------
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2024-01-06 22:35:53.424 DEBUG (MainThread) [custom_components.chime_tts] Invalid audio filepath provided
2024-01-06 22:35:53.427 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("/media/notify/pa_announce.mp3", 100.0, audio)
2024-01-06 22:35:53.428 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving audio from path: "/media/notify/pa_announce.mp3"...
2024-01-06 22:35:53.549 DEBUG (MainThread) [custom_components.chime_tts] - ...retrieved successfully. Audio duration: 2.438s
2024-01-06 22:35:53.550 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='Good Night Andy!', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:35:53.550 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:35:53.662 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 112.456 ms
2024-01-06 22:35:53.666 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='It is currently -2 degrees,', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:35:53.666 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:35:53.781 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 115.075 ms
2024-01-06 22:35:53.786 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='and Clear.', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:35:53.786 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:35:54.145 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 359.56300000000005 ms
2024-01-06 22:35:54.149 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='The forecast today is', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:35:54.149 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:35:54.266 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 117.18900000000001 ms
2024-01-06 22:35:54.271 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='Partly Cloudy with a high of 4 and a low of -2', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:35:54.272 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:35:54.975 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 703.335 ms
2024-01-06 22:35:54.984 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='tts.piper', message='You are on cat sitting duty today.', tts_playback_speed=100.0, cache=False, language=None, options={})
2024-01-06 22:35:54.985 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:35:55.103 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 118.795 ms
2024-01-06 22:35:55.113 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created. Duration: 18.75s
2024-01-06 22:35:55.113 DEBUG (MainThread) [custom_components.chime_tts] - Saving mp3 file...
2024-01-06 22:35:55.114 DEBUG (MainThread) [custom_components.chime_tts] - Audio folder exists: /media/sounds/temp/chime_tts/
2024-01-06 22:35:55.498 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/media/sounds/temp/chime_tts/lhujhyr1.mp3'
2024-01-06 22:35:55.498 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully
2024-01-06 22:35:55.499 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/media/sounds/temp/chime_tts/lhujhyr1.mp3', 'audio_duration': 18.75}
2024-01-06 22:35:55.499 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:
2024-01-06 22:35:55.499 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2024-01-06 22:35:55.499 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/lhujhyr1.mp3
2024-01-06 22:35:55.499 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.andylaptop_honor']
2024-01-06 22:35:55.528 DEBUG (MainThread) [custom_components.chime_tts] ...media_player.play_media completed.
2024-01-06 22:35:55.528 DEBUG (MainThread) [custom_components.chime_tts] Waiting 18.75s for audio playback to complete...
2024-01-06 22:36:14.280 DEBUG (MainThread) [custom_components.chime_tts] Waiting 0.25s for final_delay to complete...
2024-01-06 22:36:14.531 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 21107.648 ms -----
2024-01-06 22:36:14.531 DEBUG (MainThread) [custom_components.chime_tts] Removing current queued service call.
2024-01-06 22:36:14.531 DEBUG (MainThread) [custom_components.chime_tts] Queue emptied. Reinitializing values.

Iā€™m glad to hear your experience has improved. Are you saying all thebjssues you reported in your first post are now resolved?

Regarding the delays: before v0.11.0 the delays were ā€˜baked intoā€™ the cached files, but that should not be the case since v0.11.0. I will verify tomorrow when I get a chance.

1 Like

Up to now yes, the issues have not cropped back up again, and I suspect itā€™s because of the empty message handling now. I have seen that logged -

2024-01-06 22:31:41.224 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2024-01-06 22:31:41.348 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 124.098 ms
2024-01-06 22:31:41.358 WARNING (MainThread) [custom_components.chime_tts] TTS message missing from messsage segment #9
2024-01-06 22:31:41.358 WARNING (MainThread) [custom_components.chime_tts] {'type': 'tts', 'message': ''}
2024-01-06 22:31:41.360 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created. Duration: 18.122s

I think it just used to crash before, without generating a final audio file.

I have tried swapping the media player variable between different players and when I run the script it plays on the correct player AND something I hadnā€™t mentioned before, it correctly restores the volume now. I was having an issue where it would mute the volume on my laptop after playing the file, even though the volume was initially at full volume. That seems to be working correctly with this version.

This is absolutely brilliant work, and I have just donated for your hard work!

1 Like

Hi!

So now nothing works with the downloaded Beta 2 version, should I go back and re-download version 1 like you instructed? I did number 2 because I figured you did an update after you did version 1. Hereā€™s my logs:

2024-01-06 18:02:18.459 ERROR (MainThread) [custom_components.chime_tts] Timeout reached on queued job #1.
2024-01-06 18:02:18.465 WARNING (MainThread) [custom_components.chime_tts] Unable to find audio file None
2024-01-06 18:02:18.471 WARNING (MainThread) [custom_components.chime_tts] Unable to find audio file None
2024-01-06 18:02:18.562 ERROR (MainThread) [homeassistant.components.automation.a_test] A_Test: Error executing script. Unexpected error for call_service at pos 3: Could not speed up AudioSegment, it was too short 0.08s for the current settings:
150ms chunks at 1.1x speedup
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 713, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 675, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 117, in async_say
    result = await start_queue(service, hass, async_say_execute)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 416, in start_queue
    result = await asyncio.wait_for(task, timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 489, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 203, in async_say_execute
    audio_dict = await async_get_playback_audio_path(params, options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 821, in async_get_playback_audio_path
    output_audio = await async_process_segment(hass, segments, output_audio, params, options)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 952, in async_process_segment
    tts_audio = await async_request_tts_audio(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 718, in async_request_tts_audio
    audio = audio.speedup(playback_speed=playback_speed)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydub/effects.py", line 77, in speedup
    raise Exception("Could not speed up AudioSegment, it was too short {2:0.2f}s for the current settings:\n{0}ms chunks at {1:0.1f}x speedup".format(
Exception: Could not speed up AudioSegment, it was too short 0.08s for the current settings:
150ms chunks at 1.1x speedup
2024-01-06 18:02:18.568 ERROR (MainThread) [homeassistant.components.automation.a_test] While executing automation automation.a_test
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 669, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1587, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 426, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 479, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 502, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 713, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 675, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 117, in async_say
    result = await start_queue(service, hass, async_say_execute)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 416, in start_queue
    result = await asyncio.wait_for(task, timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 489, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 203, in async_say_execute
    audio_dict = await async_get_playback_audio_path(params, options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 821, in async_get_playback_audio_path
    output_audio = await async_process_segment(hass, segments, output_audio, params, options)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 952, in async_process_segment
    tts_audio = await async_request_tts_audio(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 718, in async_request_tts_audio
    audio = audio.speedup(playback_speed=playback_speed)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydub/effects.py", line 77, in speedup
    raise Exception("Could not speed up AudioSegment, it was too short {2:0.2f}s for the current settings:\n{0}ms chunks at {1:0.1f}x speedup".format(
Exception: Could not speed up AudioSegment, it was too short 0.08s for the current settings:
150ms chunks at 1.1x speedup
2024-01-06 18:03:51.819 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.11.1-beta2 -----
2024-01-06 18:03:51.819 DEBUG (MainThread) [custom_components.chime_tts] Service call #1 was added to the queue.
2024-01-06 18:03:51.819 DEBUG (MainThread) [custom_components.chime_tts] ...waiting for 2 previous queued jobs to complete.

I tried going back to vers. 10 and still didnā€™t work. Hereā€™s my logs:

2024-01-06 18:41:15.237 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.10.2 -----
2024-01-06 18:41:15.237 DEBUG (MainThread) [custom_components.chime_tts] Service call #5 was added to the queue.
2024-01-06 18:41:15.237 DEBUG (MainThread) [custom_components.chime_tts] Executing queued job #3
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts] ----- General Parameters -----
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * entity_ids = ['media_player.couch_echo_right_amz', 'media_player.couch_echo_left_amz', 'media_player.kitchen_echo_plus_amz', 'media_player.bathroom_echo_amz', 'media_player.apartment_door_echo_amz', 'media_player.colton_s_echo_show']
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * chime_path = /config/www/sounds/Female_Saying_Did_You_Hear_That.mp3
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * end_chime_path = 
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * cache = False
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * delay = 50.0
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * message =   
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * tts_platform = amazon_polly
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * tts_playback_speed = 115.0
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * announce = True
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * volume_level = -1.0
2024-01-06 18:41:15.242 DEBUG (MainThread) [custom_components.chime_tts]  * join_players = False
2024-01-06 18:41:15.243 DEBUG (MainThread) [custom_components.chime_tts]  * unjoin_players = False
2024-01-06 18:41:15.243 DEBUG (MainThread) [custom_components.chime_tts]  * ffmpeg_args = -y -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 -write_xing 0
2024-01-06 18:41:15.243 DEBUG (MainThread) [custom_components.chime_tts] ----- TTS-Specific Params -----
2024-01-06 18:41:15.243 DEBUG (MainThread) [custom_components.chime_tts] -------------------------------
2024-01-06 18:41:15.243 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2024-01-06 18:41:15.243 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("/config/www/sounds/Female_Saying_Did_You_Hear_That.mp3", 0, audio)
2024-01-06 18:41:15.244 DEBUG (MainThread) [custom_components.chime_tts]  - Retrieving audio from path: "/config/www/sounds/Female_Saying_Did_You_Hear_That.mp3"...
2024-01-06 18:41:15.332 DEBUG (MainThread) [custom_components.chime_tts]  - ...retrieved successfully. Audio duration: 1.115s
2024-01-06 18:41:15.332 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(hass, tts_platform = amazon_polly, message =   , tts_playback_speed = 115.0, cache = False, language = None, options = {})
2024-01-06 18:41:15.332 DEBUG (MainThread) [custom_components.chime_tts]  - Generating TTS audio...
2024-01-06 18:41:15.705 DEBUG (MainThread) [custom_components.chime_tts]  -  ...changing TTS playback speed to 115.0 percent
2024-01-06 18:41:15.706 ERROR (MainThread) [homeassistant.components.automation.testing1] Testing1: Error executing script. Unexpected error for call_service at pos 1: Could not speed up AudioSegment, it was too short 0.08s for the current settings:
150ms chunks at 1.1x speedup
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 713, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 675, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 116, in async_say
    result = await start_queue(service, hass, async_say_execute)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 409, in start_queue
    result = await asyncio.wait_for(task, timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 489, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 196, in async_say_execute
    audio_dict = await async_get_playback_audio_path(params, options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 815, in async_get_playback_audio_path
    tts_audio = await async_request_tts_audio(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 716, in async_request_tts_audio
    audio = audio.speedup(playback_speed=playback_speed)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydub/effects.py", line 77, in speedup
    raise Exception("Could not speed up AudioSegment, it was too short {2:0.2f}s for the current settings:\n{0}ms chunks at {1:0.1f}x speedup".format(
Exception: Could not speed up AudioSegment, it was too short 0.08s for the current settings:
150ms chunks at 1.1x speedup
2024-01-06 18:41:15.711 ERROR (MainThread) [homeassistant.components.automation.testing1] While executing automation automation.testing1
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 669, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1587, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 426, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 479, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 502, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 713, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 675, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 116, in async_say
    result = await start_queue(service, hass, async_say_execute)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 409, in start_queue
    result = await asyncio.wait_for(task, timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 489, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 196, in async_say_execute
    audio_dict = await async_get_playback_audio_path(params, options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 815, in async_get_playback_audio_path
    tts_audio = await async_request_tts_audio(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 716, in async_request_tts_audio
    audio = audio.speedup(playback_speed=playback_speed)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydub/effects.py", line 77, in speedup
    raise Exception("Could not speed up AudioSegment, it was too short {2:0.2f}s for the current settings:\n{0}ms chunks at {1:0.1f}x speedup".format(
Exception: Could not speed up AudioSegment, it was too short 0.08s for the current settings:
150ms chunks at 1.1x speedup

Hey @ColtonYYZ, both beta versions contained the fix I included so you were fine to use the second one. The error in your latest comment is different from the one the previou one. The new error looks to be related to making speed adjustments to TTS audio:

Exception: Could not speed up AudioSegment, it was too short 0.08s for the current settings:
150ms chunks at 1.1x speedup

The service call in the debug logs shows that no message string was included, so this error doesnā€™t make sense to me. Are you certain you reproduced this same error with the second beta? Iā€™s only asking because that release specifically dealt with empty message strings, and the code responsible for speeding up TTS audio should never have been reached.

If this issue persisted after downgrading back to the previous version I suspect the issue may be unrelated to the changes in v0.11.0. I suggest you remove the integration, reboot Home Assistant, install it again and reboot. Hopefully that should resolve the issue.

The pauses between these files, which have been cached at this point, was a bit irritating, but changing the global delay to 100 has made this much more palatable. Is this intended behaviour? As the docs suggested that value was just a delay before the audio started?

Thank you for bringing this up Andrew - I just updated the documentation to explain how you can add delay to both TTS and chime segment types so that you can adjust or remove the delay before any segment :+1:

1 Like

I just wanted to second finding some way to combine this with the notify tts service would be really useful.

So I did a backup and went back to the previous version of Chime TTS and Alexa Media Player. I was able to get it working again. Then I upgraded everything except Alexa Media Player. Iā€™m about to do that now and will let you know if all is well!

Update: Itā€™s working now for me again, with everything updated to the newest version! Thanks for your help once again!

Btw, for anyone who gets the message, ā€œSorry, Iā€™m having trouble accessing your Simon Says NA skill right nowā€, go to Alexa Media Player, click on Configure, and check to make sure your public URL (I use the Nabucasa URL) has the trailing ā€˜/ā€™ without the quotes, at the end. It took me forever to figure this out!

Hi @ColtonYYZ, iā€™m happy to hear everythingā€™s working again for you!

Your tip regarding the trailing ā€˜/ā€™ actually highlights a bug which I will fix in the next release - thank you too :+1:

I got the beta release fixing the / issue. So far all is great! If you need further testing with Alexa speakers, feel free to shoot me a DM and I will be happy to help!

Thanks for all you do man! I am impressed with how active you are with us users! It takes time away from your friends and family but I can speak on behalf of everyone else, and say thank you!

1 Like

Great to hear itā€™s working again for you!
Thank you Colton, I appreciate your kind words :grinning:

Does anyone use the join option set to true with Sonos within ChimeTTS and is this working? Or are you all using the join / unjoin form Sonos itself?

Iā€™ve only gotten it to play on a single Sonos so far. even on stereo pairs it only plays on one speaker.

iā€™ts been a bit hard to work with because there seem to be a few issues / possibilities of improvement:

  1. Thereā€™s sometimes a very long delay for me (10+ seconds) between calling the service and getting output on the speakers, or the service finishing with a url to play. not sure how I could debug this, but ā€œregularā€ tts responds much faster.
  2. the announce function does not work as expected with my sons speakers - using the home-assistant native media_player.play_media with the announce flag set to true, will keep playing the music quietly and overlay the content to play. ChimeTTS will instead completely stop playback (and so far not start it again, for me at least).
  3. it would be great to overlay chime and tts message by a few milliseconds (eg a negative delay) for chimes that fade out such as Engaged - Ringtones, message tones and other sounds where it would be great the have the tts come in when the chime has become quiet but is still playing.

for 1) feedback on debugging would be great.
for 2) Iā€™m trying to use something like

service: media_player.play_media
target:
  entity_id: media_player.wohnzimmer
data:
  announce: true
  media_content_type: music
  media_content_id: <audio src="{{chime_tts.url}}" />
  extra:
    volume: 75

but its not yet working, I think mostly because of the first point - the delay

Hi @KrisHoobie & @afiwube.
Unfortunately I donā€™t own any Sonos speakers so I canā€™t debug with actual hardware. I know other users have used the Sonos integration to join the speakers into a group, and then Chime TTS with the newly formed speaker group.

Perhaps other Sonos uses in this forum topic might be able to lend some advice?

Regarding the points @afiwube raised:

  1. Thereā€™s sometimes a very long delay for me (10+ seconds) between calling the service and getting output on the speakers, or the service finishing with a url to play. not sure how I could debug this, but ā€œregularā€ tts responds much faster.

The delay duration is based on the time required to generate the TTS audio, how many chimes you are using, and their durations. If you enable debugging you will be able to see how long each step of the mp3 generation process takes. Another source of delay is playback to the actual speaker.

Chime TTS uses the native media_player.play_media service, and I am not aware of a faster/better way to achieve playback.

All that being said: I am happy to review your debug logs to try to understand if thereā€™s some other issue/s causing delays.

  1. the announce function does not work as expected with my sons speakers - using the home-assistant native media_player.play_media with the announce flag set to true, will keep playing the music quietly and overlay the content to play. ChimeTTS will instead completely stop playback (and so far not start it again, for me at least).

As I said above, Chime TTS uses the media_player.play_media service, so the Chime TTS announce parameter should perform the same way. I will revisit the announce flag to see what might be wrong there (again I donā€™t own any speakers which support the feature which makes the task more difficult).

Could you please provide debug logs? Perhaps they might provide further insight.

  1. it would be great to overlay chime and tts message by a few milliseconds (eg a negative delay) for chimes that fade out such as Engaged - Ringtones, message tones and other sounds where it would be great the have the tts come in when the chime has become quiet but is still playing.

This is a great suggestion and I will implement it for an upcoming release :+1:

thanks for the debug info!

iā€™ve enabled debugging (how do I disable it?) and made 3 tests.

for the first one text I did not hear anything on the speakers. I noticed in the logs it had a different chime selected than the one I had selected in the service call.

for the second one I change the text to ā€œdebugā€ and changed announce to true. the sound immediately played, but oddly with the previous text ā€œessenā€.

for the third one I change the text to ā€œdebug at 18:13ā€ it again immediately played a sound but again heard the previous ā€œdebugā€ instead of the expected ā€œdebug at 18:13ā€

there seems to be an off by one error in the queue? which maybe I previously thought was a delay (I hadnā€™t changed the text)

Iā€™ll restart and try again at a later time.

Log Entries
2024-01-16 18:09:02.442 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.11.1 -----

2024-01-16 18:09:02.442 DEBUG (MainThread) [custom_components.chime_tts] Service call #19 was added to the queue.

2024-01-16 18:09:02.442 DEBUG (MainThread) [custom_components.chime_tts] Executing queued job #18

2024-01-16 18:09:02.443 DEBUG (MainThread) [custom_components.chime_tts] ----- General Parameters -----

2024-01-16 18:09:02.443 DEBUG (MainThread) [custom_components.chime_tts] * entity_ids = []

2024-01-16 18:09:02.444 DEBUG (MainThread) [custom_components.chime_tts] * chime_path = custom_components/chime_tts/mp3s/microphone_tap.mp3

2024-01-16 18:09:02.444 DEBUG (MainThread) [custom_components.chime_tts] * end_chime_path =

2024-01-16 18:09:02.444 DEBUG (MainThread) [custom_components.chime_tts] * cache = True

2024-01-16 18:09:02.444 DEBUG (MainThread) [custom_components.chime_tts] * delay = 450.0

2024-01-16 18:09:02.444 DEBUG (MainThread) [custom_components.chime_tts] * message = test, test, test

2024-01-16 18:09:02.445 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = google_translate

2024-01-16 18:09:02.445 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0

2024-01-16 18:09:02.445 DEBUG (MainThread) [custom_components.chime_tts] * announce = False

2024-01-16 18:09:02.445 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = -1.0

2024-01-16 18:09:02.445 DEBUG (MainThread) [custom_components.chime_tts] * join_players = False

2024-01-16 18:09:02.445 DEBUG (MainThread) [custom_components.chime_tts] * unjoin_players = False

2024-01-16 18:09:02.446 DEBUG (MainThread) [custom_components.chime_tts] ----- TTS-Specific Params -----

2024-01-16 18:09:02.446 DEBUG (MainThread) [custom_components.chime_tts] -------------------------------

2024-01-16 18:09:02.446 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path

2024-01-16 18:09:02.446 DEBUG (MainThread) [custom_components.chime_tts] Attempting to retrieve generated mp3 file from cache

2024-01-16 18:09:02.446 DEBUG (MainThread) [custom_components.chime_tts] - async_get_cached_audio_data('59c1eeccb9f17cb925d1c61e552593418069e6f581653d7a77ecc1ef435771e1')

2024-01-16 18:09:02.447 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving key/value from chime_tts storage:

2024-01-16 18:09:02.447 DEBUG (MainThread) [custom_components.chime_tts] - key: 59c1eeccb9f17cb925d1c61e552593418069e6f581653d7a77ecc1ef435771e1

2024-01-16 18:09:02.447 DEBUG (MainThread) [custom_components.chime_tts] - value: {'audio_path': '/www/chime_tts/4o6tm16c.mp3', 'audio_duration': 3.947}

2024-01-16 18:09:02.450 DEBUG (MainThread) [custom_components.chime_tts] - Cached audio data found

2024-01-16 18:09:02.450 DEBUG (MainThread) [custom_components.chime_tts] Using previously generated mp3 saved in cache

2024-01-16 18:09:02.450 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/www/chime_tts/4o6tm16c.mp3', 'audio_duration': 3.947}

2024-01-16 18:09:02.451 DEBUG (MainThread) [custom_components.chime_tts] Final URL = http://192.168.178.40:8123/local/chime_tts/4o6tm16c.mp3

2024-01-16 18:09:02.451 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say URL Completed in 7.475 ms -----

2024-01-16 18:09:02.451 DEBUG (MainThread) [custom_components.chime_tts] Removing current queued service call.

2024-01-16 18:09:02.451 DEBUG (MainThread) [custom_components.chime_tts] Incrementing to next queued service call.

2024-01-16 18:12:18.748 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.11.1 -----

2024-01-16 18:12:18.748 DEBUG (MainThread) [custom_components.chime_tts] Service call #20 was added to the queue.

2024-01-16 18:12:18.748 DEBUG (MainThread) [custom_components.chime_tts] Executing queued job #19

2024-01-16 18:12:18.749 DEBUG (MainThread) [custom_components.chime_tts] ----- General Parameters -----

2024-01-16 18:12:18.749 DEBUG (MainThread) [custom_components.chime_tts] * entity_ids = ['media_player.wohnzimmer']

2024-01-16 18:12:18.749 DEBUG (MainThread) [custom_components.chime_tts] * chime_path = /media/notify/1-fingerlicking-message-tone.mp3

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * end_chime_path =

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * cache = False

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * delay = 450.0

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * message = Essen!

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = google_translate

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * announce = False

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = -1.0

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * join_players = False

2024-01-16 18:12:18.750 DEBUG (MainThread) [custom_components.chime_tts] * unjoin_players = False

2024-01-16 18:12:18.751 DEBUG (MainThread) [custom_components.chime_tts] ----- TTS-Specific Params -----

2024-01-16 18:12:18.751 DEBUG (MainThread) [custom_components.chime_tts] -------------------------------

2024-01-16 18:12:18.751 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path

2024-01-16 18:12:18.751 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("/media/notify/1-fingerlicking-message-tone.mp3", 0, None)

2024-01-16 18:12:18.756 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving audio from path: "/media/notify/1-fingerlicking-message-tone.mp3"...

2024-01-16 18:12:19.063 DEBUG (MainThread) [custom_components.chime_tts] - ...retrieved successfully. Audio duration: 6.88s

2024-01-16 18:12:19.063 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='google_translate', message='Essen!', tts_playback_speed=100.0, cache=False, language=None, options={})

2024-01-16 18:12:19.063 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...

2024-01-16 18:12:19.685 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 621.159 ms

2024-01-16 18:12:19.689 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created. Duration: 8.193s

2024-01-16 18:12:19.693 DEBUG (MainThread) [custom_components.chime_tts] - Saving mp3 file...

2024-01-16 18:12:20.016 DEBUG (MainThread) [custom_components.chime_tts.helpers] - File saved successfully

2024-01-16 18:12:20.016 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/media/sounds/temp/chime_tts/l0xie68c.mp3'

2024-01-16 18:12:20.016 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully

2024-01-16 18:12:20.017 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/media/sounds/temp/chime_tts/l0xie68c.mp3', 'audio_duration': 8.193}

2024-01-16 18:12:20.017 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:

2024-01-16 18:12:20.017 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music

2024-01-16 18:12:20.017 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/l0xie68c.mp3

2024-01-16 18:12:20.017 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.wohnzimmer']

2024-01-16 18:12:20.102 DEBUG (MainThread) [custom_components.chime_tts] ...media_player.play_media completed.

2024-01-16 18:12:20.103 DEBUG (MainThread) [custom_components.chime_tts] Waiting 8.193s for audio playback to complete...

2024-01-16 18:12:28.305 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 9556.374 ms -----

2024-01-16 18:12:28.305 DEBUG (MainThread) [custom_components.chime_tts] Removing current queued service call.

2024-01-16 18:12:28.306 DEBUG (MainThread) [custom_components.chime_tts] Incrementing to next queued service call.

2024-01-16 18:13:43.459 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.11.1 -----

2024-01-16 18:13:43.459 DEBUG (MainThread) [custom_components.chime_tts] Service call #21 was added to the queue.

2024-01-16 18:13:43.460 DEBUG (MainThread) [custom_components.chime_tts] Executing queued job #20

2024-01-16 18:13:43.460 DEBUG (MainThread) [custom_components.chime_tts] ----- General Parameters -----

2024-01-16 18:13:43.461 DEBUG (MainThread) [custom_components.chime_tts] * entity_ids = ['media_player.wohnzimmer']

2024-01-16 18:13:43.461 DEBUG (MainThread) [custom_components.chime_tts] * chime_path = /media/notify/1-fingerlicking-message-tone.mp3

2024-01-16 18:13:43.461 DEBUG (MainThread) [custom_components.chime_tts] * end_chime_path =

2024-01-16 18:13:43.461 DEBUG (MainThread) [custom_components.chime_tts] * cache = False

2024-01-16 18:13:43.461 DEBUG (MainThread) [custom_components.chime_tts] * delay = 450.0

2024-01-16 18:13:43.461 DEBUG (MainThread) [custom_components.chime_tts] * message = Debug

2024-01-16 18:13:43.461 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = google_translate

2024-01-16 18:13:43.462 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0

2024-01-16 18:13:43.462 DEBUG (MainThread) [custom_components.chime_tts] * announce = True

2024-01-16 18:13:43.462 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = -1.0

2024-01-16 18:13:43.462 DEBUG (MainThread) [custom_components.chime_tts] * join_players = False

2024-01-16 18:13:43.462 DEBUG (MainThread) [custom_components.chime_tts] * unjoin_players = False

2024-01-16 18:13:43.462 DEBUG (MainThread) [custom_components.chime_tts] ----- TTS-Specific Params -----

2024-01-16 18:13:43.462 DEBUG (MainThread) [custom_components.chime_tts] -------------------------------

2024-01-16 18:13:43.462 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path

2024-01-16 18:13:43.463 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("/media/notify/1-fingerlicking-message-tone.mp3", 0, None)

2024-01-16 18:13:43.467 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving audio from path: "/media/notify/1-fingerlicking-message-tone.mp3"...

2024-01-16 18:13:43.779 DEBUG (MainThread) [custom_components.chime_tts] - ...retrieved successfully. Audio duration: 6.88s

2024-01-16 18:13:43.780 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='google_translate', message='Debug', tts_playback_speed=100.0, cache=False, language=None, options={})

2024-01-16 18:13:43.780 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...

2024-01-16 18:13:44.345 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 565.239 ms

2024-01-16 18:13:44.349 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created. Duration: 8.241s

2024-01-16 18:13:44.350 DEBUG (MainThread) [custom_components.chime_tts] - Saving mp3 file...

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts.helpers] - File saved successfully

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/media/sounds/temp/chime_tts/k4p1d5sk.mp3'

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/media/sounds/temp/chime_tts/k4p1d5sk.mp3', 'audio_duration': 8.241}

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/k4p1d5sk.mp3

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts] - announce: True

2024-01-16 18:13:44.703 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.wohnzimmer']

2024-01-16 18:13:44.909 DEBUG (MainThread) [custom_components.chime_tts] ...media_player.play_media completed.

2024-01-16 18:13:44.910 DEBUG (MainThread) [custom_components.chime_tts] Waiting 8.241s for audio playback to complete...

2024-01-16 18:13:53.154 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 9693.512999999999 ms -----

2024-01-16 18:13:53.154 DEBUG (MainThread) [custom_components.chime_tts] Removing current queued service call.

2024-01-16 18:13:53.154 DEBUG (MainThread) [custom_components.chime_tts] Incrementing to next queued service call.

Hi Lukas,

To disable the logging you can call the following service:

service: logger.set_level
  data:
    custom_components.chime_tts: warning

Thank you for the debug logs. I saw that the queue order was incorrect. A restart would fix the issue, but I just released a new version, v0.12.0, which contains a fix which might help. Can you please upgrade and check if the issue is resolved?

hey! so after a restart everything has been working great. thank you so much for this great addition!

Iā€™d love to see the feature of overlaying the chime with the TTS. Also, is there a way to adjust the volume? my chime is quite a bit louder than the aws polly generated speech. it would be great to have them be the the same volume.

ok, so Iā€™ve been playing with it, and tried ā€œjoin playersā€ wich resulted in an ā€œunknown errorā€. Deselecting union players got audio again but unfortunately with the offset error agin (playing the previous text that resulted in an unknown error).

Since that one output Iā€™ve been unable to get chimeTTS say to play anything.

Hi Lukas,

I need to address the queue issue where failed service calls to chime_tts.say cause the queue to misbehave, I hope to get to it soon. A workaround solution that doesnā€™t require you to restart Home Assistant is to restart the integration:

Settings ā†’ Devices & services ā†’ Chime TTS ā†’ ā‹® ā†’ ā†» Reload

In the meantime I have released a hotfix, v0.12.1-beta1, which includes the overlap feature and the ability to apply an FFmpeg conversion job to specific message segments, eg:

service: chime_tts.say
target:
  entity_id: media_player.kitchen
data:
  tts_platform: google_translate
  message:
    - type: chime
      path: toast
      audio_conversion: "-filter:a volume=2.5"
    - type: tts
      message: May I please have your attention?
      delay: -800

The above YAML will play the ā€œToastā€ chime at 250% its original volume, and overlay the TTS with the chime, so that the TTS starts 800ms earlier (it starts playing in the last 800ms of the chime).

Please upgrade to the new beta version and let me know if it works for you.


To install the new beta version:

  1. Open the Chime TTS repository in HACS

  2. Click on the ā‹® button in the top right

  3. Select the ā†» Redownload option

  4. Enable the Show beta versions option (it may take a moment to update the list)

  5. Select version v0.12.1-beta1 from the updated version drop-down list (again, it might need a moment)

  6. Restart Home Assistant

1 Like