Adjusting TTS Volume for Sonos Announcements?

Hi,

I’m currently working on setting up some automations with TTS via my Sonos speakers. Everything is working fine, but what I want to achieve is to have the spoken TTS text announced at a specific volume level. When it comes to MP3 files, this works well: the music continues to play in the background, but the music file is played at a set volume. However, I haven’t found a good way to implement this for TTS announcements.

Could anyone help me find a solution for controlling the TTS volume independently, similar to how an MP3 file is handled?

Thanks in advance!

If you play the TTS with media_player.play_media you can change the volume as you would with an MP3 file:

target:
  entity_id:
    - media_player.your_speaker
data:
  announce: true
  media_content_id: |
    media-source://tts/amazon_polly?message="your message"
  media_content_type: music
  extra:
    volume: 50
action: media_player.play_media

Replacing amazon_polly with the name of your TTS engine.

Been experiencing SONOS volume drop off similar to others… Appreciate any thoughts.

Have been setting up a daily dose of dad jokes announcemnts in our house. All working good but for some reason when calling the TTS action the volume drops , so the joke is not very loud

Have tried setting speaks to max volume before TTS : is there a config setting for TTS for sound I need to set as well?

YAML below : some elements are me testing the sound levels via different TTS…
—————-

alias: Joke Announcing (DADJOKES)
description: ""
triggers:
  - trigger: time
    at: "07:40:00"
  - trigger: time
    at: "08:40:00"
  - trigger: time
    at: "09:30:00"
conditions:
  - condition: or
    conditions:
      - condition: time
        after: "07:37:00"
        weekday:
          - fri
          - thu
          - wed
          - tue
          - mon
      - condition: time
        after: "08:37:00"
        weekday:
          - fri
          - thu
          - wed
          - tue
          - mon
      - condition: time
        after: "09:27:00"
        weekday:
          - sat
          - sun
actions:
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 1
    target:
      entity_id:
        - media_player.cctv_announce
        - media_player.kitchen
  - action: tts.google_translate_say
    metadata: {}
    data:
      cache: false
      message: There Is A Dad Joke Incoming.... Drum roll please...
      entity_id: media_player.cctv_announce
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 1
    target:
      device_id: d9988d3579cbf937d29d97ef3a9813a9
  - action: tts.cloud_say
    metadata: {}
    data:
      cache: false
      entity_id: media_player.kitchen
      message: "Testing loudness here "
  - action: tts.google_translate_say
    metadata: {}
    data:
      cache: false
      entity_id: media_player.cctv_announce
      message: "{{ states('sensor.joke') }}"
    enabled: false
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.4
    target:
      entity_id:
        - media_player.cctv_announce
        - media_player.kitchen
  - action: homeassistant.update_entity
    metadata: {}
    data:
      entity_id:
        - sensor.joke
  - action: tts.speak
    metadata: {}
    data:
      cache: true
      media_player_entity_id: media_player.kitchen
      message: "Testing here "
    target:
      entity_id: tts.home_assistant_cloud
    enabled: false
mode: single

From where did you get the extra: volume: parameter? It does not exist in the documentation for the base media player integration, so if anything it must’ve been self-invented by the developer of some specific media player integration only (Alexa?).

Edit: I see the Sonos integration does mention this parameter in their documentation. Could be useful I suppose, but if they want to invent parameters like this why oh why would they not use the exact same key volume_level and value range 0–1 as the standard media_player.set_volume action uses?!

1 Like