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

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.

Good catch!
That’s strange, that the voice change happens on the second call. I will continue to look into it :+1:

@Nimrod_Dolev , sorry for the delay! I have tested out the chime_tts.say and I MUST use the encoder option you added (thank you for this!) in order for all the built in chimes to work. I’ve also tested typing my /local/ url including filename of the mp3 I have in a folder - which works great too!

For Alexa users, they MUST use the announce function in order for it to work also. And maybe it’s just my setup but I couldn’t get google_translate to work, but was able to get Amazon Polly to work with the functions aforementioned.

I couldn’t figure out how to use chime_tts.say_url to work. I tried several ways of inserting a Custom URL; using with and without <audio src....> nabucasa url with file name appended to the end but I think I’m not doing a few things right.

Wouldn’t say_url also need the ‘Announce’ function that chime_tts.say has in order for say_url to work correctly? If i’m able to use a local path url to a filename in a folder I have created and stored my own mp3’s, is the say_url function really necessary since the local URL is accepted and works in chime_tts.say? It seems redundant to me, but again, maybe I am missing the point of the say_url function altogether.

Here’s a sample automation I created based on triggering the doorbell:

alias: A_Test
description: ""
trigger:
  - platform: event
    event_type: amcrest
    event_data:
      event: CallNoAnswered
      payload:
        action: Start
    enabled: true
condition: []
action:
  - service: chime_tts.say
    data:
      announce: true
      join_players: true
      unjoin_players: true
      cache: true
      chime_path: /config/www/sounds/Kids_Show_Chopped.mp3
      audio_conversion: Alexa
      tts_platform: amazon_polly
    target:
      device_id:
        - af70e16c6931257151f80b6ce86d5153
        - eb6e6046a6c8b41db1f12f09f5811ae3
        - bec8cf8ad0fcf70965e8eb5cce0f4654
        - ef5af0a1e39fc38663be1d260e347f40
        - 7b6411bf17ee856f7ee2e0389f092dfa
        - cbe11566dd6ed0a334f41fc51566c1f1
  - service: chime_tts.say
    data:
      tts_playback_speed: 115
      announce: true
      audio_conversion: Alexa
      tts_platform: amazon_polly
      message: Hey Colton, someone's at the door!
      chime_path: /config/www/sounds/Female_Saying_Did_You_Hear_That.mp3
      delay: 50
      join_players: true
      unjoin_players: true
      cache: true
      final_delay: 50
    target:
      device_id:
        - af70e16c6931257151f80b6ce86d5153
        - eb6e6046a6c8b41db1f12f09f5811ae3
        - bec8cf8ad0fcf70965e8eb5cce0f4654
        - ef5af0a1e39fc38663be1d260e347f40
        - 7b6411bf17ee856f7ee2e0389f092dfa
        - cbe11566dd6ed0a334f41fc51566c1f1
mode: single


Hi, I was looking for a tts service that simply allows me to send alerts to my Google Home (choosing which ones) and then restart the Spotify music that was playing on this Google Home.

I came here because I read that this service allows it but I’m having difficulty configuring it. or rather, I think I have some configuration problems before even configuring this service.

this configuration works, I did a test and I hear the message, but if the device was transmitting music with Spotify for example, the music stops, but at the end of the message the music does not start again:

service: chime_tts.say
target:
device_id: 91fd4c6a647ba712e9344ef67f46266d
data:
chime_path: “”
end_chime_path: “”
delay: 450
final_delay: 0
tts_playback_speed: 100
volume_level: 1
message: Prova
tts_platform: google_translate

another strange thing noticed, only Google translate works (already working directly with its dedicated service tts.google_translate_say) but all the others available don’t work. I hear the beep from Google home, but then no audio. do you have any idea why? I definitely did something wrong in the configuration

Thanks in advance to anyone who can show me a solution or some dedicated guide to understand if I have configuration problems elsewhere in Home Assistant.

Hey @Diegocampy, did you enable “Announce” option? I don’t have a google home to test it out, but if you didn’t activate the Announce function, activate it and run your automation again to see if it worked.

I try this configuration, work bat the voice is female and not male, and the message Contains strange words with number and punctuation marks​:roll_eyes::man_shrugging:t2:

service: chime_tts.say
target:
device_id: f11d528c6fd01bd3bdb6420084331ada
data:
chime_path: “”
end_chime_path: “”
delay: 450
final_delay: 0
tts_playback_speed: 100
volume_level: 0.35
message: "Prova messaggio con chime "
tts_platform: picotts

@Diegocampy, I was able to get Pico TTS to work using the chimes included but it doesn’t say the message “Prova messaggio con chime”. Instead, it says something to the effect of: “underscore 0 underscore underscore 0 minus 1”

I noticed in the PicoTTS page, it says the audio output must be wav. Chime_TTS output is mp3. So maybe this is the reason for the weird saying the girl is saying.

Also, PicoTTS doesn’t support changing male/female option so you’re stuck with the female.

When pasting your code here, click on the </> icon in the toolbar at the top of the text box where you’re typing. Then in between the ``` characters, paste your code. This way the formatting is correct, making it easier for people to troubleshoot for you. Here’s your coding:

service: chime_tts.say
data:
  announce: true
  tts_platform: picotts
  language: it-IT
  volume_level: 0.35
  message: Prova messaggio con chime
  chime_path: chirp
target:
  device_id:
    - f11d528c6fd01bd3bdb6420084331ada
1 Like

@Diegocampy I got it to work with Edge TTS which is free. You can install it using this github: Edge TTS

Then in your config file add this:

tts:
  - platform: edge_tts
    language: it-IT-DiegoNeural

Then, using this in your automation, should work for you now:

service: chime_tts.say
data:
  delay: 450
  tts_platform: edge_tts
  language: it-IT
  announce: true
  message: Prova messaggio con chime
  chime_path: chirp
target:
  device_id:
    - f11d528c6fd01bd3bdb6420084331ada
1 Like