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
149 stars 12 forks source link

Failure to readjust volume on Alexas after playing output from chime_tts:say #94

Closed dbullendsl closed 2 months ago

dbullendsl commented 4 months ago

System Health details

System Information

version core-2024.2.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.1
os_name Linux
os_version 6.1.74-haos
arch x86_64
timezone America/Chicago
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4800 Installed Version | 1.34.0 Stage | running Available Repositories | 1398 Downloaded Repositories | 35
AccuWeather can_reach_server | ok -- | -- remaining_requests | 17
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 11.5 -- | -- update_channel | stable supervisor_version | supervisor-2024.02.0 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 457.7 GB disk_used | 17.1 GB healthy | true supported | true board | generic-x86-64 supervisor_api | ok version_api | ok installed_addons | Duck DNS (1.15.0), File editor (5.8.0), Studio Code Server (5.15.0), Advanced SSH & Web Terminal (17.1.1), Samba Backup (5.2.0), Z-Wave JS (0.4.4), Mosquitto broker (6.4.0), ESPHome (2024.2.0), Zigbee2MQTT (1.35.3-1), Piper (1.4.0), Whisper (1.0.2)
keymaster zwave_integration | zwave_js -- | -- network_status | on
Dashboards dashboards | 4 -- | -- resources | 22 views | 45 mode | storage
Recorder oldest_recorder_run | February 19, 2024 at 11:41 PM -- | -- current_recorder_run | February 24, 2024 at 8:57 AM estimated_db_size | 753.38 MiB database_engine | sqlite database_version | 3.44.2
Sonoff version | 3.6.0 (8dd8af9) -- | -- cloud_online | 0 / 1 local_online | 1 / 1 debug | failed to load:
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

Alexa devices do not return to prior playback levels after playing output chime_tts:say if the devices were already playing from another source, ie Spotify.

It appears from the log that the call waits for the Alexa to return from Playing to not playing, but if the devices have been playing prior to the announcement they remain in playing mode and never signal the end of the announcement.

What I did in the past using the chime_tts:say_url call which returned the URL and the duration of the announcement. I'd wait a period equal to the duration+2 seconds and then issue a set volume command.

Reproduction steps

  1. play something on the target device like Spotify at volume level .2
  2. observe device volume level and that it's in state playing
  3. run chime_tts:say with a test announcement at volume level .4
  4. observe device is still in state playing with volume level .4 ...

Debug logs

024-02-24 09:01:42.042 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v0.13.1-beta13 -----
2024-02-24 09:01:42.042 DEBUG (MainThread) [custom_components.chime_tts.queue_manager] Adding service call to queue
2024-02-24 09:01:42.055 DEBUG (MainThread) [custom_components.chime_tts.helpers] ``` is_say_url = False
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers] ----- General Parameters -----
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * entity_ids = ['media_player.kitchen_echo_show']
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * cache = False
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * offset = 200.0
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * final_delay = 0.0
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * message = This is a test
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * tts_platform = tts.piper
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * tts_playback_speed = 100.0
2024-02-24 09:01:42.056 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * announce = False
2024-02-24 09:01:42.057 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * volume_level = 0.4
2024-02-24 09:01:42.057 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * join_players = False
2024-02-24 09:01:42.057 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * unjoin_players = False
2024-02-24 09:01:42.057 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * audio_conversion = -y -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 -write_xing 0
2024-02-24 09:01:42.058 DEBUG (MainThread) [custom_components.chime_tts.helpers] ----- TTS-Specific Params -----
2024-02-24 09:01:42.058 DEBUG (MainThread) [custom_components.chime_tts.helpers]  * voice = en_US-lessac-medium
2024-02-24 09:01:42.059 DEBUG (MainThread) [custom_components.chime_tts]  - Generating new TTS audio with parameters:
2024-02-24 09:01:42.059 DEBUG (MainThread) [custom_components.chime_tts]     * tts_platform = 'tts.piper'
2024-02-24 09:01:42.059 DEBUG (MainThread) [custom_components.chime_tts]     * message = 'This is a test'
2024-02-24 09:01:42.059 DEBUG (MainThread) [custom_components.chime_tts]     * tts_playback_speed = 100.0
2024-02-24 09:01:42.059 DEBUG (MainThread) [custom_components.chime_tts]     * cache = False
2024-02-24 09:01:42.059 DEBUG (MainThread) [custom_components.chime_tts]     * language = 'None'
2024-02-24 09:01:42.059 DEBUG (MainThread) [custom_components.chime_tts]     * options = {'voice': 'en_US-lessac-medium'}
2024-02-24 09:01:42.908 DEBUG (MainThread) [custom_components.chime_tts]    ...TTS audio completed in 849.121 ms
2024-02-24 09:01:42.908 DEBUG (MainThread) [custom_components.chime_tts]  - Saving mp3 file to folder: /config/www/chime_tts/...
2024-02-24 09:01:42.959 DEBUG (MainThread) [custom_components.chime_tts.helpers]  - File saved to path: /config/www/chime_tts/p_iso113.mp3
2024-02-24 09:01:42.959 DEBUG (MainThread) [custom_components.chime_tts]   - Performing FFmpeg audio conversion...
2024-02-24 09:01:43.041 DEBUG (MainThread) [custom_components.chime_tts]     ...FFmpeg audio conversion completed.
2024-02-24 09:01:43.046 DEBUG (MainThread) [custom_components.chime_tts]  - Saving data to chime_tts storage:
2024-02-24 09:01:43.047 DEBUG (MainThread) [custom_components.chime_tts]    - key:   "3c2a551ff3ac09369100066fc1b8c8a4ef31cdf7fd8e532ba502a3706208f10b"
2024-02-24 09:01:43.047 DEBUG (MainThread) [custom_components.chime_tts]    - value: "{'public_path': '/config/www/chime_tts/p_iso113.mp3', 'audio_duration': 1.152}"
2024-02-24 09:01:43.048 DEBUG (MainThread) [custom_components.chime_tts]  - Chime TTS audio generated: {'audio_duration': 1.152, 'local_path': None, 'public_path': 'https://davebhome.duckdns.org:443/local/chime_tts/p_iso113.mp3'}
2024-02-24 09:01:43.048 DEBUG (MainThread) [custom_components.chime_tts]  - Setting 'media_player.kitchen_echo_show' volume level to 0.4
2024-02-24 09:01:43.049 DEBUG (MainThread) [custom_components.chime_tts]  - 1 Alexa media player detected. Calling `notify.alexa_media` service
2024-02-24 09:01:43.049 DEBUG (MainThread) [custom_components.chime_tts] Calling notify.alexa_media with data:
2024-02-24 09:01:43.049 DEBUG (MainThread) [custom_components.chime_tts]  - message: <audio src="https://davebhome.duckdns.org:443/local/chime_tts/p_iso113.mp3"/>
2024-02-24 09:01:43.049 DEBUG (MainThread) [custom_components.chime_tts]  - data: {'type': 'tts'}
2024-02-24 09:01:43.049 DEBUG (MainThread) [custom_components.chime_tts]  - target: ['media_player.kitchen_echo_show']
2024-02-24 09:01:43.049 DEBUG (MainThread) [custom_components.chime_tts] Waiting 1.152s for audio playback to complete...
2024-02-24 09:01:44.202 DEBUG (MainThread) [custom_components.chime_tts.helpers]  - Waiting until media_player.kitchen_echo_show is no longer = playing...
2024-02-24 09:01:54.446 WARNING (MainThread) [custom_components.chime_tts.helpers]  - Timed out waiting for media_player.kitchen_echo_show's state to change from playing
2024-02-24 09:01:54.446 WARNING (MainThread) [custom_components.chime_tts] Timed out waiting for playback to complete
2024-02-24 09:01:54.446 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 12390.992 ms -----


### Diagnostics dump

_No response_
nimroddolev commented 2 months ago

Hi @dbullendsl,

I believe this issue was fixed in v1.0.0 Can you please let me know if it still happens for you in the new version?

Thank you.

nimroddolev commented 2 months ago

@dbullendsl, do you have an update?

dbullendsl commented 2 months ago

working ok for me now - close