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
  entity_id: media_player.bedroom
  message: >
    My message here
  cache: false
    volume: 0.1

Use media_player.play_media

service: media_player.play_media
  announce: true
  media_content_type: music
  media_content_id: >-
    media-source://tts/cloud?message="Good evening!"
    volume: 0.1
  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"