Open issuluca opened 2 weeks ago
Hi @issuluca, thank you for opening the issue.
This should have been possible already, but thanks to your issue I discovered that there's a bug preventing it from working properly. I have added a bugfix for the issue that will be available in the next release.
Once the fix is released, the way to do this is by using message segments and applying the audio_conversion
parameter to the MP3 file to reduce its volume, eg:
action: chime_tts.say
target:
entity_id: media_player.kitchen
data:
message:
- chime: fanfare
audio_conversion: Volume 35%
- tts: TTS over quieter MP3
offset: -3000
cache: false
Ohh thank you!!! This is awesome!!! Great work ๐
Hi @issuluca, I just released the fix in v1.1.5-beta1. Can you please upgrade to the new beta version and let me know if the issue is now resolved for you?
Sorry, but it seems nothing has changed, this way I decrease the volume of both... this is my configuration:
action: chime_tts.say
target:
entity_id: media_player.salotto
data:
chime_path: /config/www/media/sounds/IronMan.mp3
offset: -50000
tts_platform: amazon_polly
volume_level: 0.39
announce: true
fade_audio: true
audio_conversion: Volume 100%
tts: TTS over quieter MP3
cache: false
message: >-
Buongiorno. Sono le {{states('sensor.time')}}minuti...... Le previsioni
per oggi dicono che sarร {{states('sensor.meteo_it')}}..... La
temperatura esterna รจ di
{{state_attr('weather.forecast_casa','temperature')}} gradi, La temperatura
in casa รจ di {{states('sensor.temperatura_sala_temperature')}} gradi.....
Il consumo attuale รจ di
{{states('sensor.shellyem_244cab4174c4_channel_1_power')}} watt....
Passa una buona giornata
I see in your YAML you have the following:
...
volume_level: 0.39
audio_conversion: Volume 100%
...
Can you please try the following instead:
...
audio_conversion: Volume 39%
...
Yes, you're right, sorry, I copied the wrong file. Actually I put 10% to see the difference, then I put it at 100% to do other tests, but in any case when I change the percentage it lowers the volume of both, I also tried to put it at 200% and in this way it increases the volume of both files
Applying audio_conversion: Volume 39%
will reduce the volume of the MP3 file itself (hard coded in the MP3) whereas using volume_level: 0.39
will set the volume of the media_player, and leaving the volume of the MP3 file as-is.
I did some more testing, but I still get the same result
Can you plese send me the full YAML for your chime_tts.say
action call and the debug log messages for it?
Here is the script I use:
alias: iromtts2
sequence:
- action: media_player.volume_set
metadata: {}
data:
volume_level: 0.7
target:
entity_id: media_player.salotto
- action: chime_tts.say
target:
entity_id: media_player.salotto
data:
chime_path: /config/www/media/sounds/IronMan.mp3
offset: -50000
tts_platform: amazon_polly
audio_conversion: Volume 39%
tts: TTS over quieter MP3
cache: false
message: >-
Buongiorno. Sono le {{states('sensor.time')}}minuti...... Le previsioni
per oggi dicono che sarร {{states('sensor.meteo_it')}}..... La
temperatura esterna รจ di
{{state_attr('weather.forecast_casa','temperature')}} gradi, La
temperatura in casa รจ di
{{states('sensor.temperatura_sala_temperature')}} gradi..... Il
consumo attuale รจ di
{{states('sensor.shellyem_244cab4174c4_channel_1_power')}} watt....
Passa una buona giornata
description: ""
icon: mdi:chat
and this is the debug
2024-10-01 17:45:08.081 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2024-10-01 17:45:08.081 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โ Chime TTS Say Called. Version v1.1.5-beta1 โ
2024-10-01 17:45:08.095 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2024-10-01 17:45:08.096 DEBUG (MainThread) [custom_components.chime_tts.queue_manager] Adding service call to queue
2024-10-01 17:45:08.097 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โญโโโโโโโโโโโโโโโโโโโโโฎ
2024-10-01 17:45:08.097 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โ General Parameters โ
2024-10-01 17:45:08.097 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โฐโโโโโโโโโโโโโโโโโโโโโฏ
2024-10-01 17:45:08.097 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * entity_ids = ['media_player.salotto']
2024-10-01 17:45:08.097 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * chime_path = /config/www/media/sounds/IronMan.mp3
2024-10-01 17:45:08.097 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * cache = False
2024-10-01 17:45:08.100 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * offset = -50000.0
2024-10-01 17:45:08.100 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * final_delay = 0.0
2024-10-01 17:45:08.100 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * message = Buongiorno. Sono le 17:45minuti...... Le previsioni per oggi dicono che sarร cielo nuvoloso..... La temperatura esterna รจ di 18.7 gradi, La temperatura in casa รจ di 22.5 gradi..... Il consumo attuale รจ di 172.16 watt.... Passa una buona giornata
2024-10-01 17:45:08.100 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * tts_platform = amazon_polly
2024-10-01 17:45:08.100 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * tts_speed = 100.0
2024-10-01 17:45:08.101 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * tts_pitch = 0
2024-10-01 17:45:08.101 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * announce = False
2024-10-01 17:45:08.101 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * fade_audio = False
2024-10-01 17:45:08.101 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * volume_level = -1
2024-10-01 17:45:08.101 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * join_players = False
2024-10-01 17:45:08.101 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * unjoin_players = False
2024-10-01 17:45:08.101 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * audio_conversion = -filter:a volume=0.39
2024-10-01 17:45:08.105 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * media_players_array:
2024-10-01 17:45:08.105 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] - 0: entity_id: media_player.salotto
2024-10-01 17:45:08.105 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] platform: cast
2024-10-01 17:45:08.105 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] initial volume: 0.699999988079071
2024-10-01 17:45:08.105 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] target volume: -1.0
2024-10-01 17:45:08.105 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] now playing: False
2024-10-01 17:45:08.106 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] join supported: False
2024-10-01 17:45:08.106 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] announce supported: False
2024-10-01 17:45:08.106 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โญโโโโโโโโโโโโโโโโโโฎ
2024-10-01 17:45:08.106 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โ Preparing Audio โ
2024-10-01 17:45:08.106 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โฐโโโโโโโโโโโโโโโโโโฏ
2024-10-01 17:45:08.140 DEBUG (MainThread) [custom_components.chime_tts] - Retrieving audio from path: "/config/www/media/sounds/IronMan.mp3"...
2024-10-01 17:45:11.264 DEBUG (MainThread) [custom_components.chime_tts] ...audio retrieved. Duration: 43.102s
2024-10-01 17:45:11.281 DEBUG (MainThread) [custom_components.chime_tts] - Generating new TTS audio with parameters:
2024-10-01 17:45:11.281 DEBUG (MainThread) [custom_components.chime_tts] * tts_platform = 'amazon_polly'
2024-10-01 17:45:11.282 DEBUG (MainThread) [custom_components.chime_tts] * message = 'Buongiorno. Sono le 17:45minuti...... Le previsioni per oggi dicono che sarร cielo nuvoloso..... La temperatura esterna รจ di 18.7 gradi, La temperatura in casa รจ di 22.5 gradi..... Il consumo attuale รจ di 172.16 watt.... Passa una buona giornata'
2024-10-01 17:45:11.282 DEBUG (MainThread) [custom_components.chime_tts] * cache = False
2024-10-01 17:45:11.282 DEBUG (MainThread) [custom_components.chime_tts] * language = None
2024-10-01 17:45:11.282 DEBUG (MainThread) [custom_components.chime_tts] * options = {}
2024-10-01 17:45:14.704 DEBUG (MainThread) [custom_components.chime_tts] ...TTS audio generated in 3.44s
2024-10-01 17:45:14.843 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] Performing overlay of -50000.0ms
2024-10-01 17:45:15.038 DEBUG (MainThread) [custom_components.chime_tts] - Saving mp3 file to local folder: /media/sounds/temp/chime_tts/...
2024-10-01 17:45:19.838 DEBUG (MainThread) [custom_components.chime_tts.helpers.filesystem] File saved to path: /media/sounds/temp/chime_tts/6sler6am.mp3
2024-10-01 17:45:19.838 DEBUG (MainThread) [custom_components.chime_tts] - Performing FFmpeg audio conversion...
2024-10-01 17:45:19.839 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] Running FFMpeg operation: "ffmpeg -i /media/sounds/temp/chime_tts/6sler6am.mp3 -filter:a volume=0.39 /media/sounds/temp/chime_tts/6sler6am_converted.mp3"
2024-10-01 17:45:24.437 DEBUG (MainThread) [custom_components.chime_tts] ...FFmpeg audio conversion completed.
2024-10-01 17:45:26.091 DEBUG (MainThread) [custom_components.chime_tts] - Chime TTS audio generated:
2024-10-01 17:45:26.091 DEBUG (MainThread) [custom_components.chime_tts] * audio_duration = 43.102
2024-10-01 17:45:26.091 DEBUG (MainThread) [custom_components.chime_tts] * local_path = "/media/sounds/temp/chime_tts/6sler6am.mp3"
2024-10-01 17:45:26.091 DEBUG (MainThread) [custom_components.chime_tts] * public_path = None
2024-10-01 17:45:26.091 DEBUG (MainThread) [custom_components.chime_tts] * media_content_id = "media-source://media_source/local/sounds/temp/chime_tts/6sler6am.mp3"
2024-10-01 17:45:26.094 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โญโโโโโโโโโโโโโโโโโโโโโฎ
2024-10-01 17:45:26.094 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โ Chime TTS playback โ
2024-10-01 17:45:26.094 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โฐโโโโโโโโโโโโโโโโโโโโโฏ
2024-10-01 17:45:26.094 DEBUG (MainThread) [custom_components.chime_tts] 1 Regular media player detected:
2024-10-01 17:45:26.095 DEBUG (MainThread) [custom_components.chime_tts] - media_player.salotto
2024-10-01 17:45:26.095 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media with data:
2024-10-01 17:45:26.095 DEBUG (MainThread) [custom_components.chime_tts] - entity_id: ['media_player.salotto']
2024-10-01 17:45:26.097 DEBUG (MainThread) [custom_components.chime_tts] - announce: False
2024-10-01 17:45:26.097 DEBUG (MainThread) [custom_components.chime_tts] - media_content_type: music
2024-10-01 17:45:26.097 DEBUG (MainThread) [custom_components.chime_tts] - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/6sler6am.mp3
2024-10-01 17:45:26.153 DEBUG (MainThread) [custom_components.chime_tts] - Waiting 43.102s for audio playback to complete...
2024-10-01 17:46:09.265 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] - Waiting until 1 media_player isn't playing...
2024-10-01 17:46:09.670 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper] โ media_player.salotto
2024-10-01 17:46:09.671 DEBUG (MainThread) [custom_components.chime_tts] Removing temporary file:
2024-10-01 17:46:09.672 DEBUG (MainThread) [custom_components.chime_tts.helpers.filesystem] Deleting file /media/sounds/temp/chime_tts/6sler6am.mp3
2024-10-01 17:46:09.672 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
2024-10-01 17:46:09.673 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โโโโโ Chime TTS Say Completed in 61.58 s โโโโโ
2024-10-01 17:46:09.673 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Hi @issuluca. Thanks for the additional details.
The issue you have is that you are applying the audio_conversion
to whole audio (both the chime and TTS message), instead of limited only to the chime.
You can do this by using message segments to separate the two, in order to change to volume for the chime only, like so:
action: chime_tts.say
target:
entity_id: media_player.salotto
data:
message:
- chime: /config/www/media/sounds/IronMan.mp3
audio_conversion: Volume 39%
- tts: >-
Buongiorno. Sono le {{states('sensor.time')}}minuti...... Le previsioni
per oggi dicono che sarร {{states('sensor.meteo_it')}}..... La
temperatura esterna รจ di
{{state_attr('weather.forecast_casa','temperature')}} gradi, La
temperatura in casa รจ di
{{states('sensor.temperatura_sala_temperature')}} gradi..... Il
consumo attuale รจ di
{{states('sensor.shellyem_244cab4174c4_channel_1_power')}} watt....
Passa una buona giornata
offset: -50000
tts_platform: amazon_polly
cache: false
Checklist
Is your feature request related to a problem? Please describe.
When I play an audio file overlaid on the tts audio, the music prevails over the speech and prevents good speech understanding
Describe the solution you'd like
Adjust the volume level of any music separately from the voice audio when the two are overlapping
Describe alternatives you've considered
It would be a good thing to be able to adjust the audio levels of the music file separately from that of the TTS audio.
Additional context
No response