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

Sorry if this is already answered somewhere but I couldn’t find it. I am using Chimes via the GUI and want to insert entity values into the TTS message. I couldn’t find a way to do it without switching to the YAML editor and using {{ states(‘entity’) }} but that then prevents going back to the GUI interface to tweak other parameters. The error is:

Visual editor is not supported for this configuration

  • Templates not supported in visual editor
    You can still edit your config in YAML.

Is there a way to stay within the GUI editor and still insert variables to be spoken as part of the TTS message? This is an example of what I would like to do except from within the GUI:

service: chime_tts.say
target:
entity_id:
- media_player.multizone_amp
data:
chime_path: mp3_path_placeholder-bells
end_chime_path: mp3_path_placeholder-bells
delay: 450
final_delay: 0
tts_playback_speed: 100
volume_level: 1
message: >-
Excessive Water Use Detected. The pump has run {{
states(‘counter.pump_count’) }} times today.
tts_platform: cloud

The answer is in your post.
Templates not supported in visual editor
It’s not a bug, it’s a feature

Sorry I don’t follow. If templates are not supported then why isn’t there another way insert variables into TTS from the visual editor?

I don’t know if I understand you well, templates are supported, but you don’t use them in the visual editor, but in yaml mode.

My original question was not about templates. It was about how to insert entity values into TTS using the visual editor. If templates are only for YAML then what is the method for using the visual editor to do this?

If you want to use a variable value, you cannot do without a template.
So none.

Hi @Upstatemike. Entity values can only be inserted via the UI when selecting target entities for a service. This is is a limitation of the UI in Home Assistant, not Chime TTS specifically.

1 Like

OK thanks for the explanation. I am not a programmer so it’s hard for me to understand why the visual editor can’t just designate a special character, like a $ for example, and use it to flag a variable in TTS. In other words when the visual editor encounters $entityname in a TTS string it could simply convert it to {{
states(‘entityname’) }} in YAML without forcing you to leave the visual editor or creating an error. (Or maybe there would still be an error due to other aspects of how the visual editor works?)

I can certainly understand why advanced functions might be hard for the visual editor to handle but inserting variable values into TTS strings is pretty basic functionality in Home Automation and it is a strange thing to exclude from visual editor support, especially for new folks coming from other platforms where they are already used to doing it that way.

1 Like

I appreciate the frustration. Home Assistant’s UI editor receives updates and improvements periodically but isn’t perfect.
The goal of Chime TTS is to try to improve the UI experience for TTS notifications, but it’s constrained.
Templating can be tricky and has a learning curve but it might be worth learning as it doesn’t look like it’s going anywhere.

I agree that Chime TTS is awesome. That is the chief reason I have been experimenting with migrating some of my TTS stuff from my other Home Automation platforms to Home Assistant. The fact that I have to use Templating to add variables to my messages is not a big deal really. The concern is that I can’t then go back to the visual editor and take advantage of the easy dropdown menus if I want to make a quick change to other parameters. For now I can pull the Template back out in the YAML view, then tweak what I want in the dropdowns, then reinsert the Template back when I am done.

I am not really looking for the UI folks to change anything about Templating. I just think they should consider if there shouldn’t be a different way to handle variables in TTS that does not rely on Templating at all since it does create constraits that other platforms don’t have to deal with. Until then I will live with the workaround.

Thanks again for your help with this.

Strangely, when using chime say_url, I get a response with a link, but no MP3 is ever placed in the folder, and so of course, when I go to the URL, there is no file there. Anyone else resolved this?

The issue might be caused by an incorrect folder path in your configuration. Check that the path you have for your chime_tts.say_url is a valid absolute path to a publicly facing folder:

Hi, that folder does exist, and is empty.

/root/config/www/sounds/chime_tts

Try removing /root from the start of the folder path and try again.

If you’re still having the issue, I suggest you enable debug logging and share the debug log messages here - maybe there might be something useful there:

  1. Turn on debug logging:

    service: logger.set_level
    data:
      custom_components.chime_tts: debug
    
  2. Call the service chime_tts.say_url again.

  3. Check your log messages in Home Assistant:

    https://{YOUR_HOME_ASSISTANT_ADDRESS}:8123/config/logs?filter=chime_tts
    

    and click LOAD FULL LOGS


EDIT: The issue might instead be related to your permissions. You may need to add the path to the allowlist_external_dirs in your configuration.yaml file:

homeassistant:
  allowlist_external_dirs:
    - "/root/config/www"

This is fantastic, thanks!
I can get this to work:

service: media_player.play_media
target:
  entity_id: media_player.livingroomsatellite
data:
  media_content_id: media-source://media_source/local/temp/chime_tts/announcements/t_biykyn.mp3
  media_content_type: audio/mpeg
metadata:
  media_class: music
  children_media_class: null
  navigateIds:
    - {}
    - media_content_type: app
      media_content_id: media-source://media_source

But if I try to use the full url generated by Chime TTS: Say URL, I get an error.
Is there any way to truncate the url down to:
/temp/chime_tts/announcements/t_biykyn.mp3 instead of the full url of:
http://192.168.86.193:8123/media/temp/chime_tts/announcements/t_biykyn.mp3

Currently, you can call the chime_tts.say_url service and truncate the url value from the response object:

{{ chime_tts_say_url_response.split('http://192.168.86.193:8123/media')[1] }}

The next version of Chime TTS includes a media_content_id field in the chime_tts.say_url response object, which will allow you to use it more easily with the media_player.play_media service, for example.

1 Like

Thanks - if I use

    - "/root/config/www"

it tells me it’s not a directory, but I was able to use

    - "/config/www"

without it complaining. However, it’s still not saving the file to the directory. Weirdly, the logging thinks it is! Thanks for the help.

2024-03-18 20:50:40.235 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say URL Called. Version v0.13.0 -----

2024-03-18 20:50:40.235 DEBUG (MainThread) [custom_components.chime_tts.helpers] ----- General Parameters -----

2024-03-18 20:50:40.236 DEBUG (MainThread) [custom_components.chime_tts.helpers] * entity_ids = []

2024-03-18 20:50:40.236 DEBUG (MainThread) [custom_components.chime_tts.helpers] * cache = False

2024-03-18 20:50:40.236 DEBUG (MainThread) [custom_components.chime_tts.helpers] * offset = 450.0

2024-03-18 20:50:40.237 DEBUG (MainThread) [custom_components.chime_tts.helpers] * final_delay = 0.0

2024-03-18 20:50:40.237 DEBUG (MainThread) [custom_components.chime_tts.helpers] * message = hello hello

2024-03-18 20:50:40.237 DEBUG (MainThread) [custom_components.chime_tts.helpers] * tts_platform = google_translate

2024-03-18 20:50:40.237 DEBUG (MainThread) [custom_components.chime_tts.helpers] * tts_playback_speed = 100.0

2024-03-18 20:50:40.238 DEBUG (MainThread) [custom_components.chime_tts.helpers] * announce = False

2024-03-18 20:50:40.238 DEBUG (MainThread) [custom_components.chime_tts.helpers] * volume_level = -1.0

2024-03-18 20:50:40.238 DEBUG (MainThread) [custom_components.chime_tts.helpers] * join_players = False

2024-03-18 20:50:40.238 DEBUG (MainThread) [custom_components.chime_tts.helpers] * unjoin_players = False

2024-03-18 20:50:40.239 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path

2024-03-18 20:50:40.239 DEBUG (MainThread) [custom_components.chime_tts] async_request_tts_audio(tts_platform='google_translate', message='hello hello', tts_playback_speed=100.0, cache=False, language=None, options={})

2024-03-18 20:50:40.239 DEBUG (MainThread) [custom_components.chime_tts] - Generating TTS audio...

2024-03-18 20:50:40.882 DEBUG (MainThread) [custom_components.chime_tts] - ...TTS audio completed in 642.575 ms

2024-03-18 20:50:40.882 DEBUG (MainThread) [custom_components.chime_tts] - Final audio created. Duration: 1.392s

2024-03-18 20:50:40.884 DEBUG (MainThread) [custom_components.chime_tts] - Saving mp3 file...

2024-03-18 20:50:41.089 DEBUG (MainThread) [custom_components.chime_tts.helpers] - File saved successfully

2024-03-18 20:50:41.089 DEBUG (MainThread) [custom_components.chime_tts.helpers] - File saved to path: /www/chime_tts/3wcs85cp.mp3

2024-03-18 20:50:41.089 DEBUG (MainThread) [custom_components.chime_tts] - Filepath = '/www/chime_tts/3wcs85cp.mp3'

2024-03-18 20:50:41.089 DEBUG (MainThread) [custom_components.chime_tts] - File saved successfully

2024-03-18 20:50:41.090 DEBUG (MainThread) [custom_components.chime_tts] - audio_dict = {'audio_path': '/www/chime_tts/3wcs85cp.mp3', 'audio_duration': 1.392}

2024-03-18 20:50:41.090 DEBUG (MainThread) [custom_components.chime_tts] Saving to chime_tts storage:

2024-03-18 20:50:41.090 DEBUG (MainThread) [custom_components.chime_tts] - key: "x"

2024-03-18 20:50:41.090 DEBUG (MainThread) [custom_components.chime_tts] - value: "{'audio_path': '/www/chime_tts/3wcs85cp.mp3', 'audio_duration': 1.392}"

2024-03-18 20:50:41.097 DEBUG (MainThread) [custom_components.chime_tts] Final URL = https://x.x.x:8123/local/chime_tts/3wcs85cp.mp3

2024-03-18 20:50:41.097 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say URL Completed in 861.758 ms -----

@Nimrod_Dolev Is it possible to include coding to mute the confirmation beep when changing volume levels with Alexa? There are a few articles that explain how to do it but that I found but I am not sure if you know of an easy way to do it yourself?

Reason: If I am watching a movie, I want the volume to increase on my alexa devices to alert me that someone is at the door. I don’t want to hear the BEEP prior to the chime playing, nor after when the volume is decreased.

Is this something you can implement in Chime TTS?

Hi @ColtonYYZ. I will look into it :+1:

1 Like

Something is wrong with your configuration set up. The media_content_id should be the FQN of your HA installation either through NabuCassa, DuckDNS, or your own private domain.