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

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?

I’ll investigate and see if I need to push a hotfix. Thanks for spotting this :+1:

Thanks. Shout if you need anything from me on this.

Thanks. I just released a hotfix (v0.10.1) which should fix the bug.

Much better! Thanks for the quick response :+1: I’ll go back to experimenting and playing.

One further question: is there any built-in way within this integration to get rid of the default Google Home “chime” when first sending a TTS announce down to it?

Happy to hear it fixed the issue!

is there any built-in way within this integration to get rid of the default Google Home “chime” when first sending a TTS announce down to it?

Not through this integration i’m afraid. I don’t have any Google Home speakers myself but I found this thread on the forum which might help you.

I just installed this today for the first time.

My first issue is it is not using the port of the home assistant URL of https://agilehumor.com:8123 and instead is omitting the port #

Log snippet:

2023-12-04 10:07:04.677 DEBUG (MainThread) [custom_components.chime_tts] Final URL = Coming Soon

My second issue is that it does not seem to be generating the full public URL (www path?) and using the local. As this is first time installed, unsure of expected results.

Hi @AgileHumor. I am not sure why the file paths for the generated MP3s aren’t working for your setup. I haven’t heard from any other users who ran into this issue.

  1. Could you please describe your Home Assistant instance in a little more detail? Are you running HAOS or a Docker container, etc?

  2. Which version of Chime TTS do you have installed?

  3. It would be helpful to see the debug logs for Chime TTS to better understand what the issue might be. To see debug logs for the integration please follow these steps:

    1. Turn on debug logging for Chime TTS:
    service: logger.set_level
    data:
      custom_components.chime_tts: debug
    
    1. Reload Chime TTS:

      SettingsDevices & servicesChime TTSReload

    2. Call the chime_tts.say & chime_tts.say_url services again.

    3. Check your log messages in Home Assistant:

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

      and then click LOAD FULL LOGS to view all log messages.

Hey John, I’m sorry you’re having issues. Thank you for the debug logs. Unfortunately the cause for this issue is not clear to me either.

It really is strange that calls to the chime_tts.say service work for you via the developer services tab, but not from your automations. I can’t think of why that could be, as there really shouldn’t be any difference.

While I don’t currently have a solution, I can suggest 2 troubleshooting ideas you could try to pinpoint the cause:

  1. The error from your debug logs is from the SonosMediaPlayerEntity._play_media service, so you might want to try changing the automation to use a non-Sonos media_player. If it works correctly on a regular media_player then the Sonos integration is likely the cause of the issue.

  2. Try replacing the call to Chime TTS in your automation with `media_player.play_media’ (and play any file from your media library). If it works correctly then Chime TTS is likely the cause of the issue.

1 Like

You might want to also check the media and folder paths in the integration’s configuration:
SettingsDevices & servicesChime TTSCONFIGURE

The url received its my local ip so alexa cant reproduce that. How can i get the external ip? ( Im using Nabu Casa url).

Problem: Chime TTS Chime works, but does not play any text.

Could anyone tell me what is causing this issue? Im attempting to use Google Cloud. (Google Cloud works through the built in TTS)

I am getting these errors.

2023-12-13 07:23:48.668 ERROR (SyncWorker_12) [pyobihai.const] Invalid credentials
2023-12-13 07:31:58.322 WARNING (MainThread) [custom_components.chime_tts] - Error calling tts.media_source.generate_media_source_id: Invalid TTS provider selected

This is the automation

service: chime_tts.say
data:
  chime_path: chord
  tts_platform: google_cloud
  tts_playback_speed: 120
  volume_level: 0.87
  cache: true
  announce: true
  message: Please remember to take the trashcans to the road.
target:
  entity_id: media_player.kitchen

Chime TTS works with the TTS platforms but does not add all them to your Home Assistant instance - you need to add them yourself.

In your example you specified the Google Cloud TTS platform. Have you added it?

https://github.com/nimroddolev/chime_tts/wiki/chime_tts.say#tts_platform

yeah oops. No I haven’t. I’ll look into that.

Do you happen to know if Ikea Symfonisk (sonos) speakers support speaker joining? Everything is working now, but if I try and join them, the sound only comes out of 1 speaker.

Hello :slight_smile:

i’m trying to make this work using tts.piper and a custom voice.

this is working :white_check_mark: (untill i try the non-working one bellow)

service: chime_tts.say
target:
  entity_id:
    - media_player.sonos_bureau
data:
  chime_path: /media/chimes/TGP - Janet Bing - edit.mp3
  final_delay: 0
  tts_playback_speed: 100
  volume_level: 0.5
  tts_platform: tts.piper
  message: Alert paidjerduty !

this is working too :white_check_mark:

service: tts.speak
target:
  entity_id:
    - tts.piper
data:
  cache: false
  media_player_entity_id: media_player.sonos_bureau
  message: Alert paidjerduty !
  options:
    voice: glados

this does not work :warning:

service: chime_tts.say
target:
  entity_id:
    - media_player.sonos_bureau
data:
  chime_path: /media/chimes/TGP - Janet Bing - edit.mp3
  final_delay: 0
  tts_playback_speed: 100
  volume_level: 0.5
  tts_platform: tts.piper
  message: Alert paidjerduty !
  options:
    voice: glados

also a variation i did just in case

  options:
    options:
      voice: glados

i can see this error in logs

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 111, in async_say
    result = await start_queue(service, hass, async_say_execute)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 389, 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 126, in async_say_execute
    options = parse_options_yaml(service.data)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 1220, in parse_options_yaml
    options = yaml.safe_load(options_string)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/yaml/__init__.py", line 125, in safe_load
    return load(stream, SafeLoader)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/yaml/__init__.py", line 79, in load
    loader = Loader(stream)
             ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/yaml/loader.py", line 34, in __init__
    Reader.__init__(self, stream)
  File "/usr/local/lib/python3.11/site-packages/yaml/reader.py", line 85, in __init__
    self.determine_encoding()
  File "/usr/local/lib/python3.11/site-packages/yaml/reader.py", line 124, in determine_encoding
    self.update_raw()
  File "/usr/local/lib/python3.11/site-packages/yaml/reader.py", line 178, in update_raw
    data = self.stream.read(size)
           ^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'read'

Any consecutive calls to chime_tts.say that was working before does not work, untill i restart the integration.

Service call #5 was added to the queue.
...waiting for 2 previous queued jobs to complete.
Unable to get next queued service call.
Timeout reached on queued job #1.
Timeout reached on queued job #2.

even after waiting for a bit and hopefully all the job reaching their timeout, i still have to restart the integration for first script to work again.
direct call to tts.speak keeps working

am i missing something ?
thanks !

Hey @Nimrod_Dolev! I’m sorry I didn’t get any email notifying me of your reply. I wouldn’t want you to think I was ignoring you. I appreciate your hard work on this. I can test it out and get back to you! I read the thread and it looks like you still need this tested, so I will be happy to do it for you!

Because I got it working the way I explained earlier, I moved on to other projects. So I will create a new test automation so I don’t mess up my current config.

I will update the thread with my findings! :slight_smile:

1 Like

Hi @pixeye33

The error seems to be linked to creating the TTS audio with the voice option. I am not very familiar with Piper yet, but I couldn’t find any examples for how to set an alternate voice. When you use the glados voice, is it different to the voice you have set in the Piper configuration?

Actually, the voice does not have to be a custom one for it to fail.
Using a voice that is not the default one is enough.

Piper does not allow to use a custom voice as default, this is why i have to explicitely provide the parameter.

with v0.10.2 2023-12-22

this is working :white_check_mark: (and keeps working even after the failing call, but not immediatelly after)

service: chime_tts.say
target:
  entity_id:
    - media_player.sonos_bureau
data:
  chime_path: /media/chimes/TGP - Janet Bing - edit.mp3
  final_delay: 0
  tts_playback_speed: 100
  volume_level: 0.5
  tts_platform: tts.piper
  message: Alert paidjerduty !

this is working too :white_check_mark:

service: tts.speak
target:
  entity_id:
    - tts.piper
data:
  cache: false
  media_player_entity_id: media_player.sonos_bureau
  message: Alert paidjerduty !
  options:
    voice: en-us-amy-low

this does not work :warning:

service: chime_tts.say
target:
  entity_id:
    - media_player.sonos_bureau
data:
  chime_path: /media/chimes/TGP - Janet Bing - edit.mp3
  final_delay: 0
  tts_playback_speed: 100
  volume_level: 0.5
  tts_platform: tts.piper
  message: Alert paidjerduty !
  options:
    voice: en-us-amy-low

the queue fix seems to help :slight_smile: thanks !
i can now start the first call again after a few moments (but not immediately after the failing service call)

just had another idea by looking at the code…

service: chime_tts.say
target:
  entity_id:
    - media_player.sonos_bureau
data:
  chime_path: /media/chimes/TGP - Janet Bing - edit.mp3
  final_delay: 0
  tts_playback_speed: 100
  volume_level: 0.5
  tts_platform: tts.piper
  message: Alert paidjerduty !
  options: "{'voice': 'en-us-ryan-medium'}"

and… it works ! :white_check_mark: :tada:

options needs to be passed as a string it seems :magic_wand:
(and as json is also valid yaml the parser can interpret it)

and actually it also works this way :tada:

  options: >
    voice: en-us-ryan-medium

funny thing is that when changing voice, 1st call still produces the previous voice, 2nd call produces the new one.