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

Hi @bluespice. I am not sure I understood your first question.
Are you saying the playback stops mid-way through?

Regarding the temp mp3 files: they will remain on the filesystem in the following 2 scenarios:

  1. The cache parameter is enabled

  2. The file was generated by chime_tts.say_url, in which case the file is kept in the public folder.

In both cases you can clear your temp files by calling the chime_tts.clear_cache service.

Hi @Nimrod_Dolev. Generally the chime action plays the sound and TTS. However it seems at some point it just stops working. I restart HA and it works again. I haven’t spent much time digging in but was just checking if any known issue. The automation does get triggered in every case. It’s just that the chime action seems to freeze/time out (but no sound or TTS). Once it happens, it doesn’t appear to ever work again (even if I “test” the action itself). It’s playing to a sonos speaker, which I don’t believe is an issue.

As far as I know it’s not a widespread issue. It would be helpful to have the debug logs for Chime TTS in order to understand what the issue might be.

Use the steps below to enable debug logging. Once Chime TTS freezes up again you can post your logs:

  1. Turn on debug logging:
service: logger.set_level
  data:
    custom_components.chime_tts: debug
  1. Call the service chime_tts.say again.

  2. Check your log messages in Home Assistant:
    https://{YOUR_HOME_ASSISTANT_ADDRESS}:8123/config/logs?filter=chime_tts

and then click LOAD FULL LOGS

@Nimrod_Dolev , Seems the queue gets backed up and then times out. Queue never clears I guess. Not sure why the queue isn’t processed and then why it never clears.

Is there a way to view the queue or clear it?

2023-12-02 21:06:39.888 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.9.0 -----
2023-12-02 21:06:39.888 DEBUG (MainThread) [custom_components.chime_tts] Service call #14 was added to the queue.
2023-12-02 21:06:39.889 DEBUG (MainThread) [custom_components.chime_tts] ...waiting for 4 previous queued jobs to complete.
2023-12-02 21:07:42.431 ERROR (MainThread) [custom_components.chime_tts] Timeout reached on queued job #14.
2023-12-02 21:07:42.432 DEBUG (MainThread) [custom_components.chime_tts] Removing current queued service call.
2023-12-02 21:07:42.433 DEBUG (MainThread) [custom_components.chime_tts] Incrementing to next queued service call.

After reloading Chime TTS the same test worked (as it had been until it stopped):

2023-12-02 21:23:43.203 DEBUG (MainThread) [custom_components.chime_tts] queue_timeout = 60
2023-12-02 21:23:43.203 DEBUG (MainThread) [custom_components.chime_tts] temp_path = /media/sounds/temp/chime_tts/
2023-12-02 21:23:43.204 DEBUG (MainThread) [custom_components.chime_tts] www_path = /www/chime_tts/
2023-12-02 21:23:43.204 DEBUG (MainThread) [custom_components.chime_tts] media_dir = local
2023-12-02 21:24:42.887 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.9.0 -----
2023-12-02 21:24:42.887 DEBUG (MainThread) [custom_components.chime_tts] Service call #0 was added to the queue.
2023-12-02 21:24:42.887 DEBUG (MainThread) [custom_components.chime_tts] Executing queued job #0
2023-12-02 21:24:42.888 DEBUG (MainThread) [custom_components.chime_tts] ----- General Parameters -----
2023-12-02 21:24:42.888 DEBUG (MainThread) [custom_components.chime_tts] * entity_ids = ['media_player.voice_kitchen']
2023-12-02 21:24:42.888 DEBUG (MainThread) [custom_components.chime_tts] * hass = <HomeAssistant RUNNING>
2023-12-02 21:24:42.888 DEBUG (MainThread) [custom_components.chime_tts] * chime_path = media/copper-bell-ding-1-172685.mp3
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * cache = False
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * delay = 450.0
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * message = test
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = google_cloud
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * announce = False
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = -1.0
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * join_players = False
2023-12-02 21:24:42.889 DEBUG (MainThread) [custom_components.chime_tts] * unjoin_players = False
2023-12-02 21:24:42.890 DEBUG (MainThread) [custom_components.chime_tts] ----- TTS-Specific Params -----
2023-12-02 21:24:42.890 DEBUG (MainThread) [custom_components.chime_tts] -------------------------------
2023-12-02 21:24:42.890 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2023-12-02 21:24:42.890 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("media/copper-bell-ding-1-172685.mp3", 0, audio)
2023-12-02 21:24:42.892 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: media/copper-bell-ding-1-172685.mp3
2023-12-02 21:24:42.893 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving audio from path: "/media/copper-bell-ding-1-172685.mp3"...
2023-12-02 21:24:43.343 DEBUG (MainThread) [custom_components.chime_tts] - ...audio with duration 7.032s retrieved successfully
2023-12-02 21:24:43.344 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(hass, tts_platform = google_cloud, message = test, tts_playback_speed = 100.0, cache = False, language = None)
2023-12-02 21:24:43.344 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...
2023-12-02 21:24:43.939 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 594.749 ms
2023-12-02 21:24:43.948 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created:
2023-12-02 21:24:43.948 DEBUG (MainThread) [custom_components.chime_tts] - Duration = 8.068s
2023-12-02 21:24:43.948 DEBUG (MainThread) [custom_components.chime_tts] new_audio_folder = /media/sounds/temp/chime_tts/
2023-12-02 21:24:43.949 DEBUG (MainThread) [custom_components.chime_tts] Audio folder exists: /media/sounds/temp/chime_tts/
2023-12-02 21:24:43.950 DEBUG (MainThread) [custom_components.chime_tts] - Creating mp3 file...
2023-12-02 21:24:43.952 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/media/sounds/temp/chime_tts/uky3rx8d.mp3'
2023-12-02 21:24:44.666 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully
2023-12-02 21:24:44.667 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/media/sounds/temp/chime_tts/uky3rx8d.mp3', 'audio_duration': 8.068}
2023-12-02 21:24:44.667 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:
2023-12-02 21:24:44.667 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2023-12-02 21:24:44.667 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/uky3rx8d.mp3
2023-12-02 21:24:44.668 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.voice_kitchen']
2023-12-02 21:24:44.900 DEBUG (MainThread) [custom_components.chime_tts] ...media_player.play_media completed.
2023-12-02 21:24:44.900 DEBUG (MainThread) [custom_components.chime_tts] Waiting 8.068s for audio playback to complete...
2023-12-02 21:24:52.971 DEBUG (MainThread) [custom_components.chime_tts] Final URL = http://192.168.86.156:8123/media/sounds/temp/chime_tts/uky3rx8d.mp3
2023-12-02 21:24:52.972 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 10083.015 ms -----
2023-12-02 21:24:52.972 DEBUG (MainThread) [custom_components.chime_tts] Removing current queued service call.
2023-12-02 21:24:52.972 DEBUG (MainThread) [custom_components.chime_tts] Queue emptied. Reinitializing values.

What would cause the queue to backup (and then not empty)?

I noticed the chime path had a “not found” in the log at one point. My path was:
media/camera/4.mp3

I updated it to:
/media/camera/4.mp3

Would the possible cause issues?

It’s not clear to me why the queue gets stuck.
There doesn’t seem to be any issue with the media/camera/4.mp3 media file (based on the debug logs, Chime TTS finds the file).

Unfortunately the logs you included don’t include all chime_tts.say service calls (most notably the call which failed/caused the queue to get stuck) so I can’t tell what caused the issue.

Please recreate the problem and send the full debug logs :+1:

got everything installed. Thanks for the message on my other thread…

I get this error spoken from Alexa
"To send TTS, set public URL in integration configuration"

I have no idea what that is.

I used this in dev tools

service: chime_tts.say
data:
  chime_path: bells
  end_chime_path: ""
  delay: 450
  final_delay: 0
  tts_playback_speed: 100
  volume_level: 0.68
  message: Testing 123
  tts_platform: amazon_polly
  gender: male
target:
  entity_id: media_player.kitchen_original

Hey @jazzmonger, as i’ve written here a few times - I don’t own an echo speaker so unfortunately I can’t debug this issue. Perhaps other Chime TTS users with echo speakers could give some pointers?

Invalid TTS provider - this should be a clue…

2023-12-03 12:34:41.378 WARNING (MainThread) [custom_components.chime_tts]    - Error calling tts.media_source.generate_media_source_id: Invalid TTS provider selected
2023-12-03 12:34:41.378 WARNING (MainThread) [custom_components.chime_tts] Unable to generate TTS audio
2023-12-03 12:34:41.447 WARNING (MainThread) [custom_components.alexa_media.media_player] To send TTS, set public url in integration configuration Please see the alexa_media wiki for details.https://github.com/custom-components/alexa_media_player/wiki/Configuration%3A-Notification-Component#use-the-notifyalexa_media-service
2023-12-03 12:34:43.234 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 332, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
  Bad status line "Invalid method encountered:\n\n  b'\\x16\\x03\\x01\\x02'\n    ^"
2023-12-03 12:34:43.263 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 332, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
  Bad status line "Invalid method encountered:\n\n  b'\\x16\\x03\\x01\\x02'\n    ^"

I logged an issue. Feel free to add to it.

Hi @jazzmonger, thanks for the log messages.

The log error:
Error calling tts.media_source.generate_media_source_id: Invalid TTS provider selected
suggests that the Amazon Polly TTS service is not configured correctly on your Home Assistant instance. Please call the chime_tts.say_url service with Amazon Polly as the TTS platform to see if the issue is with Amazon Polly or with the Echo speaker.

that is exactly what I’m doing ass shown in my above post… its what causes the error.

This might hold some clues…

oops… no thanks… I already paid for the gold toilet Bezos uses in his vacation house…

I just came across this and I’d like to use chime_tts for my Alerts. But for Alerts you have to set up a Notifier and I’m struggling to see how to set this up or if indeed that is even possible. Has anyone done this ? Is it possible?

1 Like

Hi @jazzmonger, I am not sure if I understood your last message. Have you configured Amazon Polly and tested it with the chime_tts.say_url service (not the chime_tts.say service)?

Hi @perjury1. What exactly are you trying to do? It wasn’t clear to me from your message.

Thanks for responding.
I’m using the Alert integration Alert - Home Assistant (home-assistant.io)
This requires that you must setup a notification integration Notify using TTS - Home Assistant

I’d like to set up Chime TTS as a notifier but I can’t work out how.

Does that explain it well enough?

I think you cash create an automation with an event trigger (the event being the notification alert) and then call the chime_tts.say service.

No doubt I can, but that wasn’t really what I was after. I was hoping to be able to set up chime_tts.say as a notifier.

Ok, well I don’t think it’s possible directly in its current form.
I will take a closer look at it when I can and perhaps add support in a future release.

OK, thanks

Amazon Polly is a paid service. No thanks…

I got my script working, so I’m good.

Hi all,

Just playing around last night with the latest (
v0.10.0) version of this integration. I have this action called from an automation:

  - service: chime_tts.say
    data:
      message: Just testing the doorbell!
      tts_platform: cloud # also tried google_translate
      volume_level: 0.7
    target:
      entity_id:
        - media_player.office_speaker
        - media_player.hallway_speaker

This resulted in the following error:

2023-12-03 20:04:05.167 ERROR (Thread-10) [homeassistant.components.cast.media_player] Failed to cast media https://<public_url>:8123/mediasoundstempchime_tts/yxmy87d7.mp3?authSig= from internal_url (https://<public_url>:8123). Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

When tested, the url returned a 404, which wasn’t surprising given the rather odd mediasoundstempchime_tts path. I’ve checked the integration config, and it’s correctly reporting the temporary MP3 folder path as /media/sounds/temp/chime_tts/

Am I doing something fundamentally daft here?