nimroddolev / chime_tts

A custom Home Assistant integration to play combined audio files before and/or after text-to-speech (TTS) messages
https://nimroddolev.github.io/chime_tts/
MIT License
196 stars 14 forks source link

TTS/Chime echos when using Sonos speakers #113

Closed mikesnook closed 7 months ago

mikesnook commented 7 months ago

System Health details

[`## System Information

version core-2024.4.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.20-haos
arch x86_64
timezone America/New_York
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1413 Downloaded Repositories | 63
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.04.0 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 30.8 GB disk_used | 21.2 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Studio Code Server (5.15.0), Advanced SSH & Web Terminal (17.2.0), Grafana (9.2.1), InfluxDB (5.0.0), zabbix-agent2 (1.4), ESPHome (2024.3.2)
Husqvarna Automower can_reach_server | ok -- | --
Dashboards dashboards | 19 -- | -- resources | 49 views | 97 mode | storage
Recorder oldest_recorder_run | April 5, 2024 at 15:11 -- | -- current_recorder_run | April 11, 2024 at 17:00 estimated_db_size | 3857.73 MiB database_engine | sqlite database_version | 3.44.2
`](url) ### Checklist - [X] I have enabled debug logging for my installation. - [X] I have filled out the issue template to the best of my ability. - [X] This issue only contains 1 issue (if you have multiple issues, open one issue for each issue). - [X] This issue is not a duplicate issue of currently [previous issues](https://github.com/nimroddolev/chime_tts/issues?q=is%3Aissue+label%3A%22Bug%22+).. ### Describe the issue When attempting to speak to a grouped set of Sonos speakers using the yaml in 'reproduction steps' section, the audio is played at different times / out of sync: As seem here from geekofweek it seems the order in which grouping, setting announce and volume is important when using Sonos speakers: https://github.com/home-assistant/core/issues/93136#issuecomment-1550408991 ### Reproduction steps This causes the out of sync audio/TTS: ``` - service: chime_tts.say data: chime_path: www/media/beep.mp3 delay: 10 announce: false final_delay: 0 tts_playback_speed: 100 message: Vehicle entering driveway. tts_platform: google_cloud join_players: true cache: true enabled: true target: entity_id: - media_player.lounge_sonos` - media_player.kitchen_sonos` - media_player.diningroom_sonos` ``` If i manually join/group players and set volume before executing chimeTTS with the following, the audio is played in sync across all speakers as it should: ``` - service: media_player.volume_set metadata: {} data: volume_level: 0.45 target: entity_id: - media_player.lounge_sonos - media_player.diningroom_sonos - media_player.kitchen_sonos - service: media_player.join data: group_members: - media_player.kitchen_sonos - media_player.diningroom_sonos target: entity_id: - media_player.lounge_sonos - service: chime_tts.say data: chime_path: www/media/beep.mp3 delay: 10 announce: false final_delay: 0 tts_playback_speed: 100 message: Vehicle entering driveway. tts_platform: google_cloud join_players: false cache: true enabled: true target: entity_id: - media_player.lounge_sonos ``` Would it be possible to allow the order of grouping / setting volume / announce setting to be modified ? ### Debug logs ```text N/A ``` ### Diagnostics dump _No response_
nimroddolev commented 7 months ago

Hi @mikesnook. Thank you for reporting this issue.

I don't have any Sonos speakers so I cannot test possible fixes myself but based on your feedback I will change the order of operations so that Chime TTS first sets the volume for each speaker before grouping them via media_player.join.

I will release a beta version soon and and ask you to please test whether the issue is fixed with this change 👍

mikesnook commented 7 months ago

Great thanks @nimroddolev yup no problem at all, regarding geekofweek's point "setting announce: false only works if the Sonos are in a group prior to the TTS message being sent", is that going to be possible as well, this seemed to cause the out of sync issues, had to join speakers manually first, then allow ChimeTTS to set the announce: false.

nimroddolev commented 7 months ago

I can't test on my end so I can't be 100%, but with that said: the fix will group the speakers before any audio playback begins (as described by geekofweek) so I think it should work.

mikesnook commented 7 months ago

totally understood, I will test when you release the beta. thank you.

nimroddolev commented 7 months ago

Hi @mikesnook, can you please tell me if you're using the native Sonos integration or the custom sonos_cloud integration?

mikesnook commented 7 months ago

Hi @mikesnook, can you please tell me if you're using the native Sonos integration or the custom sonos_cloud integration?

Hi, I'm using the native integration.

nimroddolev commented 7 months ago

Hi @mikesnook. I have added a fix in the latest beta, v1.1.0-beta3.

Can you please upgrade to the new version and let me know if it is 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 (it may take a moment to update the list)
  5. Select version v1.1.0-beta3 from the updated version drop-down list
  6. Restart Home Assistant
mikesnook commented 7 months ago

Hi @nimroddolev, great work! Chime_TTS now works as expected without the manual service call steps, the echo has gone, audio is correctly synced across the Sonos speakers.

Thank you, Mike