Using tts.cloud_say and Sonos

When using tts.cloud_say on a Sonos speaker that’s already playing music I’d like to pass the volume parameter that you are able to pass via media_player.play_media when manually passing announcement parameter. Is this possible?

More Background

I noticed today that if am playing musing on my Sonos and then use tts.cloud_say to say something on the device it’ll lower the volume and play what needs to be said. I see in the Sonos integration documentation that this is a function of the announce property that apparently is being handled on the backend.

What I Tried

service: tts.cloud_say
data:
  entity_id: media_player.bedroom
  message: >
    My message here
  cache: false
  options:
    volume: 0.1

Use media_player.play_media

service: media_player.play_media
data:
  announce: true
  media_content_type: music
  media_content_id: >-
    media-source://tts/cloud?message="Good evening!"
  extra:
    volume: 0.1
target:
  entity_id: media_player.bedroom
1 Like

That’s handy, had no idea that endpoint existed, thanks! For a more complex message or one with special characters do I just URL encode?

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.


I tried this with Google Translate as the TTS engine (I don’t have access to Nabu Casa’s TTS) and it didn’t convert %21 to an exclamation mark (it said ‘good evening quote’).

media-source://tts/google_translate?message="Good evening%21"

How about if want use a language? Here my example:

service: tts.cloud_say
metadata: {}
data:
  entity_id: media_player.soundbar
  message: 早晨,今日將係美好嘅一日。
  language: zh-HK
enabled: true

I have no idea how to get it working, why its not possible to set easy a volume in the service: tts.cloud_say?

1 Like

I suggest you consider posting your question in a new topic, where more users are likely to see and answer it, than appending it to a topic that was solved 10 months ago.

I don’t think there’s a way to specify voice or language when using Nabu Casa’s media-source://tts/cloud endpoint. I was also looking for the same, but it seems the only options are to use the more limited tts.cloud_say service (which allows you to configure TTS, but no controls for announce, volume, etc) OR to use the service media_player.play_media with the TTS endpoint, but then no ability to customize the TTS parameters.

That’s a bummer. Hope Nabu Casa folks implement this soon on TTS endpoint.

If you only need a handful of fixed messages, you could generate static files for each, and then use media_player.play_media. But every time you want to change the message you’d have to regenerate the files, so it gets boring pretty quickly.

IMHO, I do not think you should expect TTS to be read outloud in anything other than the language the device is set to.

see Introduction | Home Assistant Companion Docs

Specifically, "Current support is limited to the current Text To Speech locale set on the device. "

You can try using the Chime TTS custom integration to achieve this.

1 Like

Thanks all for your answers, i just found a way but with media_player.play_media.

Here is a script what working for me:

alias: Skript Benachrichtigung Orchidee Schlafzimmer
sequence:
  - service: media_player.play_media
    data:
      media_content_id: >-
        media-source://media_source/local/528475__robinhood76__09156-accent-chime-login.wav
      media_content_type: audio/mpeg
      announce: true
      extra:
        volume: 25
    target:
      device_id:
        - c837fe7ce89808b6c675572ebea8e9cb
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: media_player.play_media
    data:
      media_content_id: >-
        media-source://tts/cloud?message=%E5%85%B0%E8%8A%B1%E5%A4%AA%E5%B9%B2%E9%9C%80%E8%A6%81%E6%B5%87%E6%B0%B4%E3%80%82&language=zh-HK&voice=WanLungNeural
      media_content_type: music
      announce: true
      extra:
        volume: 25
    target:
      device_id:
        - c837fe7ce89808b6c675572ebea8e9cb
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - service: media_player.play_media
    data:
      media_content_id: >-
        media-source://tts/cloud?message=Die+Orchidee+ist+zu+trocken%2C+bitte+gie%C3%9Fen.&language=de-DE&voice=KatjaNeural
      media_content_type: music
      announce: true
      extra:
        volume: 25
    target:
      device_id:
        - c837fe7ce89808b6c675572ebea8e9cb
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - service: media_player.play_media
    data:
      media_content_id: >-
        media-source://media_source/local/528475__robinhood76__09156-accent-chime-login.wav
      media_content_type: audio/mpeg
      announce: true
      extra:
        volume: 25
    target:
      device_id:
        - c837fe7ce89808b6c675572ebea8e9cb
mode: single
icon: mdi:account-voice