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

Volume after TTS #118

Closed thephantom closed 5 months ago

thephantom commented 7 months ago

Checklist

Is your feature request related to a problem? Please describe.

When tts is ready, the music volume will first increase and then return to the original level. Can I also go to the original level immediately after the TTS?

Describe the solution you'd like

Goto original level whitout delay

Describe alternatives you've considered

Final Delay -400

Additional context

service: chime_tts.say metadata: {} data: tts_speed: 100 tts_pitch: 0 message: Dit i s een test! tts_platform: tts.google_nl_nl language: nl gender: female volume_level: 0.2 announce: true offset: 0 target: entity_id: media_player.office

nimroddolev commented 7 months ago

Hi @thephantom, sorry to hear you're having this issue.

Can you please tell me the platform of your media_player (media_player.office)?

thephantom commented 7 months ago

Hi,

No problem. The mediaplayer is an Sonos play 5

Met vriendelijke Groet, @.**@.>


Van: Nimrod Dolev @.> Verzonden: woensdag 17 april 2024 08:15 Aan: nimroddolev/chime_tts @.> CC: thephantom @.>; Mention @.> Onderwerp: Re: [nimroddolev/chime_tts] Volume after TTS (Issue #118)

Hi @thephantomhttps://github.com/thephantom, sorry to hear you're having this issue.

Can you please tell me the platform of your media_player (media_player.office)?

— Reply to this email directly, view it on GitHubhttps://github.com/nimroddolev/chime_tts/issues/118#issuecomment-2060457498, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAAH7KPNN5PUKKWFSJMCXBTY5YHRTAVCNFSM6AAAAABGIJHEL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRQGQ2TONBZHA. You are receiving this because you were mentioned.Message ID: @.***>

nimroddolev commented 7 months ago

Hi @thephantom, I have just released a new beta version, v1.1.0-beta3, which includes 2 changes I think might address your issue:

  1. I have improved the announce feature for Sonos-media_players specifically, to set the volume of the notification audio played on top of any playing audio.
  2. There is a new fade_audio parameter that will fade out and then pause any playing audio, play the Chime TTS notification, and then resume the original audio with a fade in. You can configure the fade during in the integration's configuration page.

I do not own any Sonos speakers, so unfortunealty I am unable to test these features on actual Sonos hardware. I would appreciate it if you could please upgrade to the new version and let me know if it works 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
thephantom commented 7 months ago

Hi @nimroddolev

I'm happy to help. I installed beta 4. when announce is off the radio does not start again.

This one works only volume does not set the tts voice harder (sound is going off). Radio is turnd off, message speaking, radio is staring again.

service: chime_tts.say metadata: {} data: message: Dit is een test! tts_platform: tts.google_nl_nl volume_level: 0.5 fade_audio: true announce: true target: entity_id: media_player.kantoor

see https://youtu.be/19Lu-ezGgsY

nimroddolev commented 7 months ago

Hi @thephantom

Thank you for testing and providing the video 👍

When announce is false the radio should not start up again as you are replacing the current audio with the Chime TTS notification (this is by design).

The volume should be fading out and fading in again afterwards, can you please provide the debug logs for when this happens?

To enable debug logging for Chime TTS:

  1. Turn on debug logging:

    service: logger.set_level
    data:
     custom_components.chime_tts: debug
  2. Call the chime_tts.say service 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

thephantom commented 7 months ago

hmmm that way does not work (or i do it wrong) but i found this log info:

2024-04-18 14:20:32.994 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v1.1.0-beta4 ----- 2024-04-18 14:20:32.995 DEBUG (MainThread) [custom_components.chime_tts.queue_manager] Adding service call to queue 2024-04-18 14:20:33.001 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ----- General Parameters ----- 2024-04-18 14:20:33.001 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] entity_ids = ['media_player.kantoor'] 2024-04-18 14:20:33.001 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] cache = False 2024-04-18 14:20:33.001 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] offset = 450.0 2024-04-18 14:20:33.002 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] final_delay = 0.0 2024-04-18 14:20:33.002 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] media_players_array = [{'entity_id': 'media_player.kantoor', 'platform': 'sonos', 'should_change_volume': True, 'initial_volume_level': 0.12, 'playback_volume_level': 0.5, 'group_members_supported': True, 'announce_supported': True, 'is_playing': True}] 2024-04-18 14:20:33.002 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] message = Dit is een test! 2024-04-18 14:20:33.002 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] tts_platform = tts.google_nl_nl 2024-04-18 14:20:33.002 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] tts_speed = 100.0 2024-04-18 14:20:33.003 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] tts_pitch = 0 2024-04-18 14:20:33.003 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce = True 2024-04-18 14:20:33.003 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] fade_audio = True 2024-04-18 14:20:33.003 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] volume_level = 0.5 2024-04-18 14:20:33.003 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join_players = False 2024-04-18 14:20:33.004 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] unjoin_players = False 2024-04-18 14:20:33.006 DEBUG (MainThread) [custom_components.chime_tts] - Generating new TTS audio with parameters: 2024-04-18 14:20:33.006 DEBUG (MainThread) [custom_components.chime_tts] tts_platform = 'tts.google_nl_nl' 2024-04-18 14:20:33.006 DEBUG (MainThread) [custom_components.chime_tts] message = 'Dit is een test!' 2024-04-18 14:20:33.007 DEBUG (MainThread) [custom_components.chime_tts] cache = False 2024-04-18 14:20:33.007 DEBUG (MainThread) [custom_components.chime_tts] language = None 2024-04-18 14:20:33.007 DEBUG (MainThread) [custom_components.chime_tts] * options = {} 2024-04-18 14:20:33.385 DEBUG (MainThread) [custom_components.chime_tts] ...TTS audio generated in 380.0ms 2024-04-18 14:20:33.385 DEBUG (MainThread) [custom_components.chime_tts] - Saving mp3 file to folder: /media/sounds/temp/chime_tts/... 2024-04-18 14:20:33.634 DEBUG (MainThread) [custom_components.chime_tts.helpers.filesystem] - File saved to path: /media/sounds/temp/chime_tts/wpza8l6s.mp3 2024-04-18 14:20:34.004 DEBUG (MainThread) [custom_components.chime_tts] - Chime TTS audio generated: 2024-04-18 14:20:34.005 DEBUG (MainThread) [custom_components.chime_tts] - audio_duration = 1.512 2024-04-18 14:20:34.005 DEBUG (MainThread) [custom_components.chime_tts] - local_path = "/media/sounds/temp/chime_tts/wpza8l6s.mp3" 2024-04-18 14:20:34.005 DEBUG (MainThread) [custom_components.chime_tts] - public_path = None 2024-04-18 14:20:34.005 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id = "media-source://media_source/local/sounds/temp/chime_tts/wpza8l6s.mp3" 2024-04-18 14:20:34.006 DEBUG (MainThread) [custom_components.chime_tts] Pre-Playback Actions 2024-04-18 14:20:34.006 DEBUG (MainThread) [custom_components.chime_tts] - Fading out media_players currently playing 2024-04-18 14:20:34.006 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player] - Fading out media_player.kantoor's volume from 0.12 to 0 over 0.5s 2024-04-18 14:20:34.536 DEBUG (MainThread) [custom_components.chime_tts] - Pausing 1 media_player 2024-04-18 14:20:34.591 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player] - Waiting until 1 media_player is paused... 2024-04-18 14:20:34.793 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player] ✔ media_player.kantoor 2024-04-18 14:20:34.794 DEBUG (MainThread) [custom_components.chime_tts] Chime TTS playback 2024-04-18 14:20:34.794 DEBUG (MainThread) [custom_components.chime_tts] 1 Sonos media player detected: 2024-04-18 14:20:34.795 DEBUG (MainThread) [custom_components.chime_tts] - media_player.kantoor 2024-04-18 14:20:34.795 DEBUG (MainThread) [custom_components.chime_tts] sonos_media_player_dict = {'entity_id': 'media_player.kantoor', 'platform': 'sonos', 'should_change_volume': True, 'initial_volume_level': 0.12, 'playback_volume_level': 0.5, 'group_members_supported': True, 'announce_supported': True, 'is_playing': True, 'fade_out_volume': 0, 'volume_steps': [0.09, 0.06, 0.03]} 2024-04-18 14:20:34.796 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media with data: 2024-04-18 14:20:34.796 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music 2024-04-18 14:20:34.796 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/wpza8l6s.mp3 2024-04-18 14:20:34.796 DEBUG (MainThread) [custom_components.chime_tts] - announce: True 2024-04-18 14:20:34.796 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.kantoor'] 2024-04-18 14:20:34.797 DEBUG (MainThread) [custom_components.chime_tts] - extra: {'volume': 0.5} 2024-04-18 14:20:34.807 DEBUG (MainThread) [custom_components.chime_tts] - Waiting 1.512s for audio playback to complete... 2024-04-18 14:20:36.323 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player] - Waiting until 1 media_player isn't playing... 2024-04-18 14:20:36.323 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player] ✔ media_player.kantoor 2024-04-18 14:20:36.324 DEBUG (MainThread) [custom_components.chime_tts] Post-Playback Actions 2024-04-18 14:20:36.324 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player] - Waiting until 1 media_player is paused... 2024-04-18 14:20:36.324 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player] ✔ media_player.kantoor 2024-04-18 14:20:36.324 DEBUG (MainThread) [custom_components.chime_tts] - Setting volume to 0 2024-04-18 14:20:36.347 DEBUG (MainThread) [custom_components.chime_tts] - Resuming 1 media_player 2024-04-18 14:20:39.192 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player] - Fading in media_player.kantoor's volume from 0.0 to 0.12 over 0.5s 2024-04-18 14:20:39.691 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 6.69 s -----

or do you need the hole log file?

nimroddolev commented 7 months ago

Thank you - this is what I was asking for 👍

Looking at the debug logs I see the following events:

  1. Faded out the audio
  2. Paused
  3. Played the Chime TTS notification (with extra:{'voume':0.5})
  4. Set the volume to 0
  5. Resumed the audio
  6. Faded in back to 12%

This all seems correct, but is this what actually happened?

thephantom commented 7 months ago

Hi,

1. Faded out the audio 2. Paused

It is stopping the audio complete

1. Played the Chime TTS notification (with extra:{'voume':0.5})

Volume change does not change the volume

  1. Set the volume to 0
  2. Resumed the audio

it start intunes radio again (you here the intune welcome message)

  1. Faded in back to 12%

The code is:

service: chime_tts.say metadata: {} data: message: Dit is een test! tts_platform: tts.google_nl_nl volume_level: 0.5 fade_audio: true announce: true target: entity_id: media_player.kantoor

so i think the music must keep playing only at an minimum so you doent need to stop it and restart it.

nimroddolev commented 7 months ago

To do that you will need to have:

nimroddolev commented 5 months ago

Can you please upgrade to the latest stable release and let me know if the issue is resolved for you?

nimroddolev commented 5 months ago

I am closing this issue. If you still encounter this issue on the latest stable release, please open a new issue with debug log messages.