Announcement on a Sonos Five speaker with a specific language and with extra volume

I have my Sonos Play 5 replaced by a Sonos Five speaker.

My original TTS script was not working good anymore with this new speaker (i was using the sonos snapshot/restore services and some delays).

But i saw that there are improvements now to use an announcement as TTS on a speaker.

But I have some problems. The requirements are:

  • TTS as an announcement over the play musing (so no stop and restore anymore)
  • the TTS must have a specific volume level.

In my config I have this specified:

# Text to speech
tts:
  - platform: google_translate
    cache: true
    cache_dir: /tmp/tts
    time_memory: 300
    service_name: google_say

Option A:

service: tts.google_say
data:
  entity_id: media_player.sonos_woonkamer
  message: De wasmachine is gereed
  language: nl

With option A I have my text announced over the music and with my Dutch (nl) language. The problem is that I can’t set the volume I think (I don’t want to have a construction to store the current volume level, increase it, do the tts and restore it to the saved volume level).

Option B:

service: media_player.play_media
data:
  announce: true
  media_content_id: media-source://tts/google_translate?message="De wasmachine is gereed"
  media_content_type: music
  extra:
    volume: 50
target:
  entity_id: media_player.sonos_woonkamer
  

With Option B I have my text announced over the music with a specific volume level. But the problem is that I don’t know how to specify my language. Now it is announced english instead of dutch (nl).

How can I combine those 2 things that it work correct?

I found it!

I have added a Google Translate text to speech integration in the UI. Here I can specify the culture. The entity_id of this new integration is tts.google_nl_nl.

Now it all works with the next service call:

service: media_player.play_media
data:
  announce: true
  media_content_id: media-source://tts/tts.google_nl_nl?message="De wasmachine is gereed"
  media_content_type: music
  extra:
    volume: 60
target:
  entity_id: media_player.sonos_woonkamer

Based on other examples posted in the forum, you can use google_translate and it will automatically detect the language from the supplied message text.

  media_content_id: media-source://tts/tts.google_translate?message="De wasmachine is gereed"

Oh strange at my sides it didn’t recognize it.

Google Translate text-to-speech - Home Assistant (home-assistant.io)