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

Hi @Nimrod_Dolev, this is really great and very useful for me. However I find that when I am listening to music I generally have a fairly low volume set on my Sonos system with a higher volume_level set for the chime. Unfortunately it seems that the volume set for the chime increases before the music is stopped and I get a short (maybe 250 ms long) burst of the music at the higher volume before it is muted.
The delay simply delays the start of the chime but not the change in volume.
Do you have any suggestions how I may improve this.
Many thanks Brian

Hi @Brain1000, thanks for the suggestion.
I just released a potential fix in a beta release, v0.7.6-beta1.

To upgrade to the beta, please do the following:

  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
  5. Select version v0.7.6-beta1 from the updated version drop-down list

Please let me know if there’s an improvement and I will incorporate it into an upcoming release.

Hi @Nimrod_Dolev, that’s fantastic it seems to have fixed the problem and very quickly too. Very many thanks.

You’re welcome, i’m glad I could help :+1:

Hi @Nimrod_Dolev,
I am not sure what is wrong. However, when I run the following code, the only thing that is played through the speakers is the chime.

service: chime_tts.say
target:
  entity_id:
    - media_player.nesthub1419
data:
  tts_platform: google_translate
  message: Hello
  chime_path: mp3_path_placeholder-chord
  tld: com.au
  cache: false

I have v0.7.5 installed.

Hi @kaizersoje. There doesn’t seem to be anything wrong with your YAML and the fact that you can hear the chime means there’s no issues with playing media.

My guess is that perhaps you have not added the Google Translate service to your Home Assistant instance. Please check your configuration.yaml file for the TTS domain, and make sure to add Google Translate:

configuration.yaml

tts:
  - platform: google_translate
    service_name: google_say

Thx @Nimrod_Dolev. That solved the issue.

Hi @ColtonYYZ, regarding using Chime TTS with your Alexa speakers: I just released a new beta version, v0.8.0-beta1, which includes a new service: chime_tts.say_url.

This new service returns an external URL to the MP3 file generated by chime_tts.say which you can use with your Alexa speakers.

chime_tts.say_url accepts the same data as chime_tts.say (just without any media_player-specific data).

I have not been able to test it (as I don’t have any Alexa speakers) but you can refer to the following YAML example:

sequence:
  - service: chime_tts.say_url
    data:
      chime_path: mp3_path_placeholder-bells_2
      tts_platform: google_translate
      message: This is a Chime TTS test on Alexa speakers
      language: en
    response_variable: chime_tts
  - service: notify.alexa_media
    data:
      message: |
        <audio src='{{chime_tts.url}}'/>
      target:
        - media_player.echo_show
        - media_player.echo_plus
        - media_player.bathroom_echo
        - media_player.bedroom_echo
      data:
        type: tts

It would be great if you could please upgrade to the beta version and report back if its working 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

  5. Select version v0.8.0-beta1 from the updated version drop-down list

I test it. but my Alexa Echo Dot response the message with the Simon Error.
The URL i add is reachable via Browser and plays direct without download. i will test again and again.

1 Like

Hi @Homealone3000, unfortunately I don’t have any Alexa speakers so I can’t troubleshoot on an actual device.

To test whether the issue is with the Alexa speaker or Chime TTS/Home Assistant you could try playing a different mp3 URL, from another site. If it plays successfully then either Chime TTS may indeed be the issue, or there could be a networking issue such as an SSL issue with the Alexa speaker.

Perhaps another Chime TTS user with an Alexa speaker could share from their experience?

Youre right we need more testers. there are too many sources of error. maybe under the video from BeardedTinker.

Hi
Can someone explain where to put the Alexa yaml to enable the Alexa
Thanks

Is there any reason why an action to play a sound and speak would just stop working–even if I manually execute it? I notice files in the temp folder that aren’t getting deleted. Is that expected?

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?