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

@jreed509 I just released a hotfix v0.5.6 - can you please let me know if it’s working again for you?

Seems like the path is not working as it still gives the error about the /config/tts/ file. See output below:

2023-07-26 17:40:38.907 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called -----
2023-07-26 17:40:38.908 DEBUG (MainThread) [custom_components.chime_tts] * hass = <homeassistant.core.HomeAssistant object at 0x744502f0>
2023-07-26 17:40:38.908 DEBUG (MainThread) [custom_components.chime_tts] * chime_path = /home/homeassistant/.homeassistant/tts/7944c5f87770f2710f409032dd78d78b3aeea91d_nl_-_google_translate.mp3
2023-07-26 17:40:38.908 DEBUG (MainThread) [custom_components.chime_tts] * end_chime_path = custom_components/chime_tts/mp3s/bells.mp3
2023-07-26 17:40:38.909 DEBUG (MainThread) [custom_components.chime_tts] * delay = 450.0
2023-07-26 17:40:38.909 DEBUG (MainThread) [custom_components.chime_tts] * message = Hi Bram this is a test
2023-07-26 17:40:38.909 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = google_translate
2023-07-26 17:40:38.909 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0
2023-07-26 17:40:38.910 DEBUG (MainThread) [custom_components.chime_tts] * entity_id = media_player.woonkamer
2023-07-26 17:40:38.910 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = 0.71
2023-07-26 17:40:38.910 DEBUG (MainThread) [custom_components.chime_tts] * cache = True
2023-07-26 17:40:38.911 DEBUG (MainThread) [custom_components.chime_tts] * announce = False
2023-07-26 17:40:38.911 DEBUG (MainThread) [custom_components.chime_tts] * language = nl
2023-07-26 17:40:38.911 DEBUG (MainThread) [custom_components.chime_tts] * tld = None
2023-07-26 17:40:38.912 DEBUG (MainThread) [custom_components.chime_tts] * gender = None
2023-07-26 17:40:38.912 DEBUG (MainThread) [custom_components.chime_tts] ------
2023-07-26 17:40:38.916 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2023-07-26 17:40:38.917 DEBUG (MainThread) [custom_components.chime_tts] Attempting to retrieve generated mp3 file from cache
2023-07-26 17:40:38.917 DEBUG (MainThread) [custom_components.chime_tts] - async_get_cached_audio_data('487cbce769bfab5e71b86abd869b7c8efc3e4b506912ef0d738e50ba45d01629')
2023-07-26 17:40:38.918 DEBUG (MainThread) [custom_components.chime_tts] - Audio data not found in cache.
2023-07-26 17:40:38.918 DEBUG (MainThread) [custom_components.chime_tts] No previously generated mp3 file found
2023-07-26 17:40:38.918 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("/home/homeassistant/.homeassistant/tts/7944c5f87770f2710f409032dd78d78b3aeea91d_nl_-_google_translate.mp3", 0, audio)
2023-07-26 17:40:38.919 DEBUG (MainThread) [custom_components.chime_tts] Retrieving audio from path: "/home/homeassistant/.homeassistant/tts/7944c5f87770f2710f409032dd78d78b3aeea91d_nl_-_google_translate.mp3"...
2023-07-26 17:40:41.219 DEBUG (MainThread) [custom_components.chime_tts] - ...audio with duration 2.4s retrieved successfully
2023-07-26 17:40:41.219 DEBUG (MainThread) [custom_components.chime_tts] Cached TTS mp3 file exists?
2023-07-26 17:40:41.219 DEBUG (MainThread) [custom_components.chime_tts] - async_get_cached_audio_data('d0f068467344cc731c5ef93696e90cb681e084f8a3a8538721a681a28f4c84f8')
2023-07-26 17:40:41.220 DEBUG (MainThread) [custom_components.chime_tts] - Audio data not found in cache.
2023-07-26 17:40:41.220 DEBUG (MainThread) [custom_components.chime_tts] - Cached TTS mp3 file not found
2023-07-26 17:40:41.220 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio_filepath(hass, tts_platform="google_translate", message="Hi Bram this is a test", language="nl", tld="None", gender="None"))
2023-07-26 17:40:41.221 DEBUG (MainThread) [custom_components.chime_tts] Requesting TTS audio:
2023-07-26 17:40:41.221 DEBUG (MainThread) [custom_components.chime_tts] * url = http://192.168.2.25:8123/api/tts_get_url
2023-07-26 17:40:41.222 DEBUG (MainThread) [custom_components.chime_tts] * headers = {'Authorization': 'Bearer eyJhb##########mbW5k', 'Content-Type': 'application/json'}
2023-07-26 17:40:41.222 DEBUG (MainThread) [custom_components.chime_tts] * data = {"message": "Hi Bram this is a test", "platform": "google_translate", "cache": true, "language": "nl"}
2023-07-26 17:40:41.222 DEBUG (MainThread) [custom_components.chime_tts] * timeout = 10
2023-07-26 17:40:41.562 DEBUG (MainThread) [custom_components.chime_tts] - Repsonse status_code: "200"
2023-07-26 17:40:41.562 DEBUG (MainThread) [custom_components.chime_tts] - Repsonse received: "{"url":"http://192.168.2.25:8123/api/tts_proxy/81e1ddbfa91c6c9a0926c017af4b0570220892b0_nl_-_google_translate.mp3","path":"/api/tts_proxy/81e1ddbfa91c6c9a0926c017af4b0570220892b0_nl_-_google_translate.mp3"}"
2023-07-26 17:40:41.562 DEBUG (MainThread) [custom_components.chime_tts] - TTS filepaths = {'path': '/config/tts/81e1ddbfa91c6c9a0926c017af4b0570220892b0_nl_-_google_translate.mp3', 'url': 'http://192.168.2.25:8123/api/tts_proxy/81e1ddbfa91c6c9a0926c017af4b0570220892b0_nl_-_google_translate.mp3'}
2023-07-26 17:40:41.564 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: "/config/tts/81e1ddbfa91c6c9a0926c017af4b0570220892b0_nl_-_google_translate.mp3"
2023-07-26 17:40:41.564 DEBUG (MainThread) [custom_components.chime_tts] - TTS file path not found on filesystem.
2023-07-26 17:40:41.565 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("custom_components/chime_tts/mp3s/bells.mp3", 450.0, audio)
2023-07-26 17:40:41.598 DEBUG (MainThread) [custom_components.chime_tts] Retrieving audio from path: "/home/homeassistant/.homeassistant/custom_components/chime_tts/mp3s/bells.mp3"...
2023-07-26 17:40:41.890 DEBUG (MainThread) [custom_components.chime_tts] - ...audio with duration 0.944s retrieved successfully
2023-07-26 17:40:41.903 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created:
2023-07-26 17:40:41.903 DEBUG (MainThread) [custom_components.chime_tts] - Duration = 3.794s
2023-07-26 17:40:41.903 DEBUG (MainThread) [custom_components.chime_tts] Create temporary mp3 file
2023-07-26 17:40:41.904 DEBUG (MainThread) [custom_components.chime_tts] Temp folder exists?
2023-07-26 17:40:41.905 DEBUG (MainThread) [custom_components.chime_tts] Creating temporary mp3 file...
2023-07-26 17:40:41.907 DEBUG (MainThread) [custom_components.chime_tts] temp_filename_obj = <tempfile._TemporaryFileWrapper object at 0x50c1edf0>
2023-07-26 17:40:41.908 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/home/homeassistant/.homeassistant/media/sounds/temp/chime_tts/cotpiv7i.mp3'
2023-07-26 17:40:42.286 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully
2023-07-26 17:40:42.287 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/home/homeassistant/.homeassistant/media/sounds/temp/chime_tts/cotpiv7i.mp3', 'audio_duration': 3.794}
2023-07-26 17:40:42.287 DEBUG (MainThread) [custom_components.chime_tts] - async_set_volume_level("media_player.woonkamer", 0.71)
2023-07-26 17:40:42.287 DEBUG (MainThread) [custom_components.chime_tts] - Seting volume_level of media player "media_player.woonkamer" to: 0.71
2023-07-26 17:40:42.726 DEBUG (MainThread) [custom_components.chime_tts] - Completed
2023-07-26 17:40:42.726 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:
2023-07-26 17:40:42.726 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: /home/homeassistant/.homeassistantmedia-source://media_source/local/sounds/temp/chime_tts/cotpiv7i.mp3
2023-07-26 17:40:42.726 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2023-07-26 17:40:42.726 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: media_player.woonkamer

Yep v0.5.6 isn’t working for me either. I can only hear TTS messages from previously cached messages, but any new text just plays the start chime sound:

2023-07-26 11:55:20.670 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called -----
2023-07-26 11:55:20.670 DEBUG (MainThread) [custom_components.chime_tts] * hass = <homeassistant.core.HomeAssistant object at 0x7fc44c6b28d0>
2023-07-26 11:55:20.670 DEBUG (MainThread) [custom_components.chime_tts] * chime_path = custom_components/chime_tts/mp3s/bells.mp3
2023-07-26 11:55:20.670 DEBUG (MainThread) [custom_components.chime_tts] * end_chime_path =
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * delay = 450.0
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * message = Hello world! 19874
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = tts.piper
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * entity_id = media_player.workshop_sonos
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = 0.52
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * cache = True
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * announce = True
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * language = None
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * tld = None
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] * gender = None
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] ------
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] Attempting to retrieve generated mp3 file from cache
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] - async_get_cached_audio_data('eb5de0339e3d16deac8d84c2955d8d0fefc5e6f7aa10426b7798014ca081aa44')
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] - Audio data not found in cache.
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] No previously generated mp3 file found
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("custom_components/chime_tts/mp3s/bells.mp3", 0, audio)
2023-07-26 11:55:20.671 DEBUG (MainThread) [custom_components.chime_tts] Retrieving audio from path: "custom_components/chime_tts/mp3s/bells.mp3"...
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] - ...audio with duration 0.944s retrieved successfully
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] Cached TTS mp3 file exists?
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] - async_get_cached_audio_data('807b2952721427c5057d83f46aaf724b0d679ad974f5b7e5a88c6a1f4ef686c7')
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] - Audio data not found in cache.
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] - Cached TTS mp3 file not found
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio_filepath(hass, tts_platform="tts.piper", message="Hello world! 19874", language="None", tld="None", gender="None"))
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] Requesting TTS audio:
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] * url = http://192.168.55.150:8123/api/tts_get_url
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] * headers = {'Authorization': 'Bearer eyJhb##########TsXEU', 'Content-Type': 'application/json'}
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] * data = {"message": "Hello world! 19874", "platform": "tts.piper", "cache": true}
2023-07-26 11:55:20.762 DEBUG (MainThread) [custom_components.chime_tts] * timeout = 10
2023-07-26 11:55:20.773 DEBUG (MainThread) [custom_components.chime_tts] - Repsonse status_code: "200"
2023-07-26 11:55:20.773 DEBUG (MainThread) [custom_components.chime_tts] - Repsonse received: "{"url":"http://192.168.55.150:8123/api/tts_proxy/c388341a1598509358847be4382bdd6b9ca2f6ba_en-us_a877e2b3bf_tts.piper.wav","path":"/api/tts_proxy/c388341a1598509358847be4382bdd6b9ca2f6ba_en-us_a877e2b3bf_tts.piper.wav"}"
2023-07-26 11:55:20.773 DEBUG (MainThread) [custom_components.chime_tts] - TTS filepaths = {'path': '/config/tts/c388341a1598509358847be4382bdd6b9ca2f6ba_en-us_a877e2b3bf_tts.piper.wav', 'url': 'http://192.168.55.150:8123/api/tts_proxy/c388341a1598509358847be4382bdd6b9ca2f6ba_en-us_a877e2b3bf_tts.piper.wav'}
2023-07-26 11:55:20.773 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: "/config/tts/c388341a1598509358847be4382bdd6b9ca2f6ba_en-us_a877e2b3bf_tts.piper.wav"
2023-07-26 11:55:20.773 DEBUG (MainThread) [custom_components.chime_tts] - TTS file path not found on filesystem.
2023-07-26 11:55:20.773 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("", 450.0, audio)
2023-07-26 11:55:20.773 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created:
2023-07-26 11:55:20.774 DEBUG (MainThread) [custom_components.chime_tts] - Duration = 0.944s
2023-07-26 11:55:20.774 DEBUG (MainThread) [custom_components.chime_tts] Create temporary mp3 file
2023-07-26 11:55:20.774 DEBUG (MainThread) [custom_components.chime_tts] Temp folder exists?
2023-07-26 11:55:20.774 DEBUG (MainThread) [custom_components.chime_tts] Creating temporary mp3 file...
2023-07-26 11:55:20.774 DEBUG (MainThread) [custom_components.chime_tts] temp_filename_obj = <tempfile._TemporaryFileWrapper object at 0x7fc41a559790>
2023-07-26 11:55:20.775 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/media/sounds/temp/chime_tts/lqrqauzj.mp3'
2023-07-26 11:55:20.829 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully
2023-07-26 11:55:20.829 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/media/sounds/temp/chime_tts/lqrqauzj.mp3', 'audio_duration': 0.944}
2023-07-26 11:55:20.829 DEBUG (MainThread) [custom_components.chime_tts] - async_set_volume_level("media_player.workshop_sonos", 0.52)
2023-07-26 11:55:20.829 DEBUG (MainThread) [custom_components.chime_tts] - Seting volume_level of media player "media_player.workshop_sonos" to: 0.52
2023-07-26 11:55:20.839 DEBUG (MainThread) [custom_components.chime_tts] - Completed
2023-07-26 11:55:20.839 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:
2023-07-26 11:55:20.839 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/lqrqauzj.mp3
2023-07-26 11:55:20.839 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2023-07-26 11:55:20.839 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: media_player.workshop_sonos
2023-07-26 11:55:20.839 DEBUG (MainThread) [custom_components.chime_tts] - announce: True
2023-07-26 11:55:20.855 DEBUG (MainThread) [custom_components.chime_tts] ...media_player.play_media completed.
2023-07-26 11:55:20.855 DEBUG (MainThread) [custom_components.chime_tts] Returning volume level to 0.32 in 0.944s...
2023-07-26 11:55:21.799 DEBUG (MainThread) [custom_components.chime_tts] - async_set_volume_level("media_player.workshop_sonos", 0.32)
2023-07-26 11:55:21.799 DEBUG (MainThread) [custom_components.chime_tts] - Seting volume_level of media player "media_player.workshop_sonos" to: 0.32
2023-07-26 11:55:21.808 DEBUG (MainThread) [custom_components.chime_tts] - Completed
2023-07-26 11:55:21.808 DEBUG (MainThread) [custom_components.chime_tts] ...volume level restored
2023-07-26 11:55:21.808 DEBUG (MainThread) [custom_components.chime_tts] Saving generated mp3 file to cache
2023-07-26 11:55:21.808 DEBUG (MainThread) [custom_components.chime_tts] Saving to chime_tts storage:
2023-07-26 11:55:21.808 DEBUG (MainThread) [custom_components.chime_tts] key: "eb5de0339e3d16deac8d84c2955d8d0fefc5e6f7aa10426b7798014ca081aa44"
2023-07-26 11:55:21.808 DEBUG (MainThread) [custom_components.chime_tts] value: "{'audio_path': '/media/sounds/temp/chime_tts/lqrqauzj.mp3', 'audio_duration': 0.944}"
2023-07-26 11:55:21.810 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 1139.819 ms -----

@Bramus it looks like there is an issue with both the path to the TTS audio file and the media source path of the generated media file: media_content_id: /home/homeassistant/.homeassistantmedia-source://media_source/local/sounds/temp/chime_tts/cotpiv7i.mp3

I have released another bugfix version, v0.5.7. Please let me know if the issue is fixed or if it persists.

@jreed509 I have fixed the missing audio bug caused by cache = false in release v0.5.7.
Please let me know if it is now working for you.

I tried yesterday (withouth debug enabled), i now can hear the start and end sounds, but no Google Translate input.

I will try to check later today when i’m at home or tomorrow to check with logging enabled.

v0.5.7 works for me with cache turned off, but with cache enabled I only here the start sound.

2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called -----
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * hass = <homeassistant.core.HomeAssistant object at 0x7f8020e21450>
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * chime_path = custom_components/chime_tts/mp3s/bells.mp3
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * end_chime_path = 
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * delay = 450.0
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * message = Hello world! This is a test from the workshop another time with cache on.
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * tts_platform = tts.piper
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * tts_playback_speed = 100.0
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * entity_id = media_player.workshop_sonos
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * volume_level = -1.0
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * cache = True
2023-08-02 17:48:34.632 DEBUG (MainThread) [custom_components.chime_tts]  * announce = True
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts]  * language = None
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts]  * tld = None
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts]  * gender = None
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts] ------
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts] Attempting to retrieve generated mp3 file from cache
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts]  - async_get_cached_audio_data('fa258df205281b92d0467f503237f1d14cda0787bd5978318329c9221401a893')
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts]  - Audio data not found in cache.
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts]  - No previously generated mp3 file found
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("custom_components/chime_tts/mp3s/bells.mp3", 0, audio)
2023-08-02 17:48:34.633 DEBUG (MainThread) [custom_components.chime_tts]  - Retrieving audio from path: "custom_components/chime_tts/mp3s/bells.mp3"...
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts]    - ...audio with duration 0.944s retrieved successfully
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts] Cached TTS mp3 file exists?
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts]  - async_get_cached_audio_data('601bf053cba000014ac17deb539e05500f190e1a614d6029b908577217af5285')
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts]  - Audio data not found in cache.
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts]  - Cached TTS mp3 file not found
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio_filepath(hass, tts_platform="tts.piper", message="Hello world! This is a test from the workshop another time with cache on.", language="None", tld="None", gender="None"))
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts] Requesting TTS audio:
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts]  * url     = http://192.168.55.150:8123/api/tts_get_url
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts]  * headers = {'Authorization': 'Bearer eyJhb##########TsXEU', 'Content-Type': 'application/json'}
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts]  * data    = {"message": "Hello world! This is a test from the workshop another time with cache on.", "platform": "tts.piper", "cache": true}
2023-08-02 17:48:34.724 DEBUG (MainThread) [custom_components.chime_tts]  * timeout = 10
2023-08-02 17:48:34.737 DEBUG (MainThread) [custom_components.chime_tts]  - Repsonse status_code: "200"
2023-08-02 17:48:34.737 DEBUG (MainThread) [custom_components.chime_tts]  - Repsonse received: "{"url":"http://192.168.55.150:8123/api/tts_proxy/b3d8530715a616d8545826ae3534f070602cd2a2_en-us_a877e2b3bf_tts.piper.wav","path":"/api/tts_proxy/b3d8530715a616d8545826ae3534f070602cd2a2_en-us_a877e2b3bf_tts.piper.wav"}"
2023-08-02 17:48:34.737 DEBUG (MainThread) [custom_components.chime_tts]  - TTS filepaths = {'path': '/config/tts/b3d8530715a616d8545826ae3534f070602cd2a2_en-us_a877e2b3bf_tts.piper.wav', 'url': 'http://192.168.55.150:8123/api/tts_proxy/b3d8530715a616d8545826ae3534f070602cd2a2_en-us_a877e2b3bf_tts.piper.wav'}
2023-08-02 17:48:34.738 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: /config/tts/b3d8530715a616d8545826ae3534f070602cd2a2_en-us_a877e2b3bf_tts.piper.wav
2023-08-02 17:48:34.738 DEBUG (MainThread) [custom_components.chime_tts]  - TTS file path not found on filesystem.
2023-08-02 17:48:34.738 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("", 450.0, audio)
2023-08-02 17:48:34.738 DEBUG (MainThread) [custom_components.chime_tts]  - Final audio created:
2023-08-02 17:48:34.738 DEBUG (MainThread) [custom_components.chime_tts]    - Duration = 0.944s
2023-08-02 17:48:34.738 DEBUG (MainThread) [custom_components.chime_tts] Creating final audio file
2023-08-02 17:48:34.738 DEBUG (MainThread) [custom_components.chime_tts]    - Temp folder exists: /media/sounds/temp/chime_tts/
2023-08-02 17:48:34.738 DEBUG (MainThread) [custom_components.chime_tts]  - Creating temporary mp3 file...
2023-08-02 17:48:34.740 DEBUG (MainThread) [custom_components.chime_tts]    - temp_obj = <tempfile._TemporaryFileWrapper object at 0x7f7fb9b5dd10>
2023-08-02 17:48:34.740 DEBUG (MainThread) [custom_components.chime_tts]    - Filepath = '/media/sounds/temp/chime_tts/4xf4uaw_.mp3'
2023-08-02 17:48:34.794 DEBUG (MainThread) [custom_components.chime_tts]    - File saved successfully
2023-08-02 17:48:34.794 DEBUG (MainThread) [custom_components.chime_tts]  - audio_dict = {'audio_path': '/media/sounds/temp/chime_tts/4xf4uaw_.mp3', 'audio_duration': 0.944}
2023-08-02 17:48:34.794 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:
2023-08-02 17:48:34.794 DEBUG (MainThread) [custom_components.chime_tts]  - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/4xf4uaw_.mp3
2023-08-02 17:48:34.794 DEBUG (MainThread) [custom_components.chime_tts]  - media_content_type: music
2023-08-02 17:48:34.795 DEBUG (MainThread) [custom_components.chime_tts]  - entity_id: media_player.workshop_sonos
2023-08-02 17:48:34.795 DEBUG (MainThread) [custom_components.chime_tts]  - announce: True
2023-08-02 17:48:34.826 DEBUG (MainThread) [custom_components.chime_tts] ...media_player.play_media completed.
2023-08-02 17:48:34.826 DEBUG (MainThread) [custom_components.chime_tts] Waiting 0.944s for audio playback to complete...
2023-08-02 17:48:35.771 DEBUG (MainThread) [custom_components.chime_tts] Saving generated mp3 file to cache
2023-08-02 17:48:35.771 DEBUG (MainThread) [custom_components.chime_tts] Saving to chime_tts storage:
2023-08-02 17:48:35.772 DEBUG (MainThread) [custom_components.chime_tts]  - key:   "fa258df205281b92d0467f503237f1d14cda0787bd5978318329c9221401a893"
2023-08-02 17:48:35.772 DEBUG (MainThread) [custom_components.chime_tts]  - value: "{'audio_path': '/media/sounds/temp/chime_tts/4xf4uaw_.mp3', 'audio_duration': 0.944}"
2023-08-02 17:48:35.776 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 1143.901 ms -----

@Bramus at least we’re making progress :+1:
Please provide the debug logs when you can to help me investigate.

@jreed509 I see from your debug logs that though the Piper TTS file looks like it is generated successfully, it was not found at the path returned from HA’s API.

I compared the previous version of Chime TTS(v0.5.6) to the current one (v0.5.7) and I did not see any changes which should affect the code concerning TTS audio files.

  1. Can you please call Chime TTS (with the Piper TTS platform and cache enabled) and confirm that the TTS file exists in the path you see in the debug log?
  2. Does it work for you if you include a new (uncached) message string, with the cache turned on?
  3. Does the same issue occur in Chime TTS when you use a different TTS platform (eg: Google Translate)?
  4. Did you upgrade/change anything in your HA instance around the time when you updated Chime TTS to v0.5.7?
  5. Can you please reboot your HA instance and try again?

As promised, below the debug output:

2023-08-03 08:36:30.368 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration chime_tts which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-08-03 11:21:42.952 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called -----
2023-08-03 11:21:42.952 DEBUG (MainThread) [custom_components.chime_tts] * hass = <homeassistant.core.HomeAssistant object at 0x74496430>
2023-08-03 11:21:42.952 DEBUG (MainThread) [custom_components.chime_tts] * chime_path = custom_components/chime_tts/mp3s/tada.mp3
2023-08-03 11:21:42.952 DEBUG (MainThread) [custom_components.chime_tts] * end_chime_path = custom_components/chime_tts/mp3s/tada.mp3
2023-08-03 11:21:42.952 DEBUG (MainThread) [custom_components.chime_tts] * delay = 450.0
2023-08-03 11:21:42.953 DEBUG (MainThread) [custom_components.chime_tts] * message = De Formule 1 race begint over 30minuten!
2023-08-03 11:21:42.953 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = google_translate
2023-08-03 11:21:42.953 DEBUG (MainThread) [custom_components.chime_tts] * tts_playback_speed = 100.0
2023-08-03 11:21:42.953 DEBUG (MainThread) [custom_components.chime_tts] * entity_id = media_player.kantoor
2023-08-03 11:21:42.953 DEBUG (MainThread) [custom_components.chime_tts] * volume_level = 0.77
2023-08-03 11:21:42.953 DEBUG (MainThread) [custom_components.chime_tts] * cache = False
2023-08-03 11:21:42.953 DEBUG (MainThread) [custom_components.chime_tts] * announce = False
2023-08-03 11:21:42.953 DEBUG (MainThread) [custom_components.chime_tts] * language = None
2023-08-03 11:21:42.954 DEBUG (MainThread) [custom_components.chime_tts] * tld = None
2023-08-03 11:21:42.954 DEBUG (MainThread) [custom_components.chime_tts] * gender = None
2023-08-03 11:21:42.954 DEBUG (MainThread) [custom_components.chime_tts] ------
2023-08-03 11:21:42.954 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2023-08-03 11:21:42.954 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("custom_components/chime_tts/mp3s/tada.mp3", 0, audio)
2023-08-03 11:21:42.957 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: custom_components/chime_tts/mp3s/tada.mp3
2023-08-03 11:21:42.960 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving audio from path: "/home/homeassistant/.homeassistant/custom_components/chime_tts/mp3s/tada.mp3"...
2023-08-03 11:21:46.297 DEBUG (MainThread) [custom_components.chime_tts] - ...audio with duration 2.323s retrieved successfully
2023-08-03 11:21:46.298 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio_filepath(hass, tts_platform="google_translate", message="De Formule 1 race begint over 30minuten!", language="None", tld="None", gender="None"))
2023-08-03 11:21:46.300 DEBUG (MainThread) [custom_components.chime_tts] Requesting TTS audio:
2023-08-03 11:21:46.300 DEBUG (MainThread) [custom_components.chime_tts] * url = http://192.168.2.25:8123/api/tts_get_url
2023-08-03 11:21:46.301 DEBUG (MainThread) [custom_components.chime_tts] * headers = {'Authorization': 'Bearer eyJhb##########mbW5k', 'Content-Type': 'application/json'}
2023-08-03 11:21:46.301 DEBUG (MainThread) [custom_components.chime_tts] * data = {"message": "De Formule 1 race begint over 30minuten!", "platform": "google_translate", "cache": true}
2023-08-03 11:21:46.301 DEBUG (MainThread) [custom_components.chime_tts] * timeout = 10
2023-08-03 11:21:46.704 DEBUG (MainThread) [custom_components.chime_tts] - Repsonse status_code: "200"
2023-08-03 11:21:46.705 DEBUG (MainThread) [custom_components.chime_tts] - Repsonse received: "{"url":"http://192.168.2.25:8123/api/tts_proxy/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3","path":"/api/tts_proxy/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3"}"
2023-08-03 11:21:46.705 DEBUG (MainThread) [custom_components.chime_tts] - TTS filepaths = {'path': '/config/tts/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3', 'url': 'http://192.168.2.25:8123/api/tts_proxy/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3'}
2023-08-03 11:21:46.706 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: /config/tts/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3
2023-08-03 11:21:46.706 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: /home/homeassistant/.homeassistant//config/tts/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3
2023-08-03 11:21:46.707 DEBUG (MainThread) [custom_components.chime_tts] - TTS file path not found on filesystem.
2023-08-03 11:21:46.707 DEBUG (MainThread) [custom_components.chime_tts] get_audio_from_path("custom_components/chime_tts/mp3s/tada.mp3", 450.0, audio)
2023-08-03 11:21:46.707 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: custom_components/chime_tts/mp3s/tada.mp3
2023-08-03 11:21:46.707 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving audio from path: "/home/homeassistant/.homeassistant/custom_components/chime_tts/mp3s/tada.mp3"...
2023-08-03 11:21:47.019 DEBUG (MainThread) [custom_components.chime_tts] - ...audio with duration 2.323s retrieved successfully
2023-08-03 11:21:47.080 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created:
2023-08-03 11:21:47.080 DEBUG (MainThread) [custom_components.chime_tts] - Duration = 5.096s
2023-08-03 11:21:47.081 DEBUG (MainThread) [custom_components.chime_tts] Creating final audio file
2023-08-03 11:21:47.084 DEBUG (MainThread) [custom_components.chime_tts] - Temp folder exists: /home/homeassistant/.homeassistant/media/sounds/temp/chime_tts/
2023-08-03 11:21:47.085 DEBUG (MainThread) [custom_components.chime_tts] - Creating temporary mp3 file...
2023-08-03 11:21:47.087 DEBUG (MainThread) [custom_components.chime_tts] - temp_obj = <tempfile._TemporaryFileWrapper object at 0x59477950>
2023-08-03 11:21:47.089 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/home/homeassistant/.homeassistant/media/sounds/temp/chime_tts/jb14bxiu.mp3'
2023-08-03 11:21:47.887 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully
2023-08-03 11:21:47.887 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/home/homeassistant/.homeassistant/media/sounds/temp/chime_tts/jb14bxiu.mp3', 'audio_duration': 5.096}
2023-08-03 11:21:47.888 DEBUG (MainThread) [custom_components.chime_tts] - async_set_volume_level("media_player.kantoor", 0.77)
2023-08-03 11:21:47.888 DEBUG (MainThread) [custom_components.chime_tts] - Seting volume_level of media player "media_player.kantoor" to: 0.77
2023-08-03 11:21:48.144 DEBUG (MainThread) [custom_components.chime_tts] - Volume set
2023-08-03 11:21:48.145 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:
2023-08-03 11:21:48.145 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/jb14bxiu.mp3
2023-08-03 11:21:48.145 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2023-08-03 11:21:48.145 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: media_player.kantoor

What I do notice is the wrong path to the TTS file:

2023-08-03 11:21:46.705 DEBUG (MainThread) [custom_components.chime_tts] - TTS filepaths = {'path': '/config/tts/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3', 'url': 'http://192.168.2.25:8123/api/tts_proxy/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3'}
2023-08-03 11:21:46.706 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: /config/tts/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3
2023-08-03 11:21:46.706 DEBUG (MainThread) [custom_components.chime_tts] File not found at path: /home/homeassistant/.homeassistant//config/tts/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3

The full path to the file is:
/home/homeassistant/.homeassistant/tts/7bcb20e535d0e6c4e96d0cecd1a4ca58adf32bc7_nl_-_google_translate.mp3

1 Like

@Nimrod_Dolev To answer your questions:

  1. Yes, I can see this file in my config folder after running chime TTS
  2. No, no change with a new uncached message (I’ve been testing this by adding a random number to the end of my message string).
  3. It does seem to be tied to Piper. Testing the same message with Google Translate seems to work fine.
  4. I did update home assistant to 2023.8.0 around the same time, but I don’t remember the exact sequence of events.
  5. No change after rebooting.

Also, I think this might have something to do with the line in the debug logs end_chime_path = in the debug logs. In most of my testing I don’t specify end_chime_path in my service call. For example the following yaml:

service: chime_tts.say
data:
  chime_path: custom_components/chime_tts/mp3s/bells.mp3
  delay: 450
  message: Hello world! 
  tts_platform: tts.piper
  entity_id: media_player.workshop_sonos
  cache: true
  announce: true

If I add end_chime_path: custom_components/chime_tts/mp3s/bells.mp3, everything works as expected and I hear the full message with Piper.

This is a great integration especially since is now supports the “announce” feature. Is there some reason that each service call cannot sent to more than one media_player entity? I like to send most of my announcements to the entire house.

I have done some additional testing on this integration and am really impressed with the performance when paired with Sonos speakers.

There are two show-stoppers for me before I can switch my entire TTS notification methodology over to this.

Show stopper #1 - I need to use a Script for the Chime_TTS service call so I can set the mode of the script to Queued so that when there are multiple notifications happening close to each other, they don’t interrupt the notification playback of the previous one. I want each notification to complete then play the one next in the queue. To do this I need to pass variables to the script via templates. This works for the message but NOT for the chime path. Below is my script.

service: chime_tts.say
data:
  end_chime_path: ""
  delay: 450
  tts_playback_speed: 100
  volume_level: 1
  message: {{ message }}
  announce: true
  tts_platform: amazon_polly
  entity_id: media_player.workout_room_2
  cache: true
  chime_path: custom_components/chime_tts/mp3s/{{ clip }}
enabled: true

Show stopper #2 - I need to send notifications to multiple speakers. It is not obvious how to do this and does not appear to support.

@Nimrod_Dolev, huge props for developing this. Would love to hear some feedback on what I am missing here. Thanks in advance.

Todd

I’m watching with interest. I played a little with this and thought it was fantastic especially when combined with announce. Two generally excellent improvements to TTS over Sonos.

However, it has been a few weeks now since I looked into it but as far as I remember,

  • Grouping is not possible with announce (a limitation with the Sonos api I believe not the HA implementation). And also,
  • How are you queueing your scripts?
    announce does not provide any ‘feedback’ as to when it is announcing or of the duration of the announcement so it is impossible to know if it has started or finished.

@Bramus I have released a new version, v0.6.0 which should fix the TTS filepath bug. Please update and let me know if it’s now working for you.

@jreed509 I have been able to reproduce the issue, and as you wrote it looks like it’s an issue with Piper. I tried adding blank audio as the end_chime and multiple delayed calls to fetch the audio (in case it’s a read lock issue) but I couldn’t get it working. I’m open to suggestions as i’ve run out of idea. If it’s related to Piper it might not be something I can fix on my own.
If anyone else has any insight into why Piper specifically has this issue please let me know.

@theadlee thanks for the feedback :+1:

I have added support for multiple media_player entitles in release v0.6.0, please upgrade and let me know if it’s working for you.

In terms of scripting, please refer to the following script example:

variables:
  message: Message variable was empty
  clip: bells.mp3
sequence:
  - service: chime_tts.say
    data:
      message: "{{message}}"
      announce: true
      tts_platform: amazon_polly
      entity_id: media_player.workout_room_2,media_player.dining_room,media_player.bedroom
      cache: true
      chime_path: custom_components/chime_tts/mp3s/{{clip}}
mode: queued

Also, in case it wasn’t clear, you can use your own mp3s - not just the ones included in Chime TTS.

@klogg thanks for the feedback.

I have added support for multiple media_player entities as well as queueing service calls in the latest release, v0.6.0.
Please upgrade, try it out, and let me know if the new version provides you with the ‘feedback’ you were after - and if not please let me know what type of change/s you’d like to see :+1:

1 Like

Thanks.
I will do, but it won’t be for a few days.

Will do thanks!