Agreed, works fine with TuneIn and Google music but not Amazon music (haven’t tried Spotify)
At least using Spotify through the Sonos app, and then using the TTS script, works. There does seem to be some difference relating to how the stream started playing though, see the bug report above. Also, there’s a fix [ https://github.com/home-assistant/home-assistant/pull/13401 ] but don’t know if that would solve the problem for the services you mention.
Hey guys, I’ve been dealing with this problem lately…
As soon as my automation runs, if the speakers are playing a song (25%), the volume goes up abruptly for like 2-3 seconds (65%), then I can listen to the announcement and then the volume goes down again (25%). That scares the crap out of me…. So basically the audio jumps to 65% for a brief moment, before I could listen to the announcement.
I’ve noticed that the problem with the audio happens when my speakers are playing a song and when the volume is 50% or less, but if the volume is 60% or more than that, the announcement works without any problem at all… And the problem gets worse the lower I put the volume, because the music jumps to >60% for a brief moment before the announcement,
I’ve tried changing the code, but I haven’t had any luck yet to make it work properly.
sonos_say:
alias: "Sonos TTS script"
sequence:
- service: media_player.sonos_snapshot
data_template:
entity_id: "{{ sonos_entity|default('media_player.dormitorio_ppal') }}"
- service: media_player.volume_set
data_template:
entity_id: "{{ sonos_entity|default('media_player.dormitorio_ppal') }}"
volume_level: "{{ volume|default(0.5) }}"
- service: tts.amazon_polly_say
data_template:
entity_id: "{{ sonos_entity|default('media_player.dormitorio_ppal') }}"
message: "{{ message }}"
- delay: "{{ delay|default('00:00:00') }}"
- wait_template: "{{ is_state(sonos_entity|default('media_player.dormitorio_ppal'), 'playing') }}"
timeout: '00:00:05'
- wait_template: "{{ not is_state(sonos_entity|default('media_player.dormitorio_ppal'), 'playing') }}"
timeout: '00:02:00'
- service: media_player.sonos_restore
data_template:
entity_id: "{{ sonos_entity|default('media_player.dormitorio_ppal') }}"
Try calling the media_player.media_stop
service before you call media_player.volume_set
.
Thank you!!! I think it’s working now!.. =D
Am I blind or what? Hassio reports something wrong with this automations, but I cant see where I had the TTS work on another test, but I’ve done something wrong here…
required key not provided @ data[‘trigger’][0][‘platform’]
#Tvättmaskin pratar när den är klar
- action:
- entity_id: input_boolean.tvattmaskin
service: input_boolean.turn_on
- entity_id: timer.tvattmaskin
service: timer.cancel
alias: Tvättmaskinen startar
condition: []
id: 'Tvattmaskin1'
trigger:
- platform: template
value_template: '{{ states.switch.tvattmaskinen_3.attributes.current_power_w < 5 }}'
- action:
- entity_id: timer.tvattmaskin
service: timer.start
alias: Tvättmaskinen stannar
condition: []
id: 'Tvattmaskin2'
trigger:
- platform: template
value_template: '{{ states.switch.tvattmaskinen_3.attributes.current_power_w < 5 }}'
- action:
- entity_id: input_boolean.tvattmaskin
service: input_boolean.turn_off
alias: Tvättmaskinen stannar
condition: []
id: 'Tvattmaskin3'
trigger:
- entity_id: timer.tvattmaskin
service: timer.finish
- action:
- service: script.turn_on
entity_id: script.say
data:
message: 'Tvättmaskinen är klar.'
alias: Tvättmaskinen talar
condition: []
id: 'Tvattmaskin4'
trigger:
- entity_id: input_boolean.tvattmaskin
platform: state
to: 'off'
I can report that for me playing spotify does not resume where it left off. Still plays TTS, but never resumes or sets volume back
has anyone gotten to the bottom of this yet?
TTS announce occurs, but i can not get sonos to resume what it was doing before (TV or music for example)
I’m trying to implement this with VoiceRSS now but for some reason the sound dosen’t start until the 2nd word…
Example: I want it to say “Alarm disarmed”, I hear “disarmed”.
Anyone else experiencing this?
After some more testing it seams it’s only my Play:5 II that has this issue, I’m guessing it has something todo with them being in stereo pairs…
I am also having trouble getting Sonos to restore after doing a TTS announcement. If I was playing through Spotify Connect and then the script runs, the announcement is made, and then after it finishes, it plays the announcement again.
I’m thinking that what’s happening is that when it’s trying to restore the playback from Spotify, it instead plays the cached TTS announcement again. Anyone else experiencing this or know how to get around it? I’d like the music to resume playing again after the announcement if possible.
Having a similar problem… if I was playing Spotify and then the script runs, it says the TTS announcement, and then says it again (I’m assuming when it tries to restore). But it never restores Spotify.
I use Amazon Polly and with ssml (which I see VoiceRSS can also use) I put a break before and after so the file starts playing with a blank space and also doesn’t cut the words at the end.
Hi… I have setup hassio and sonos, i am able to control the sonos. I want now to use tts.
the tts is enabled
tts:
- platform: google
When script tts.google_say is run i see that a new file is created under tts/xxxxxxbff_en_-_google.mp3.
on the dashboard i see that this file is sent to the sonos but there is no voice coming.
When i play this file on my PC i get the voice… Any idea what is missing ?
Sonos PLAY:5 (Gen1) is what i have, running version 8.6
“https://drive.google.com/open?id=1Lj0KKAseJ-P5UZJ0Peows0_KEnI2B3tp”
Are you using SSL?
If so who provided your cer and have you configured your configuration.yaml like so:
http:
api_password: password
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
base_url: hostname.ddns.net
Thanks… i had to remove https in base_url
base_url: https://hostname.ddns.net -> base_url: hostname.ddns.net
That fixed the issue.
Thanks
Hi @CtrlX
I am using your script for my Sonos (Big thanks)
Have you created any updates to the script?
How do I create any groups or define multiple speakers when using the “where”?
- service: script.turn_on
entity_id: script.say
data_template:
variables:
where: ‘kkken’
what: “Velkommen hjem Nina klokken er nu {{ now().strftime(’%H %M’) }}”
Thanks again your script was the only I could get working
Hi! Sorry to say, I haven’t touched it since I wrote it as it just works
Love the code and it works, but how would I go about adding more than one speaker?
Is it as simple as writing them with “;” between them?
Not looking to change it - Just trying to get an announcement to more than one speaker (-;
EDIT: I read some more of the thread and it seems waiting for ‘paused’ is a common way to do it.
Sorry and ignore my question.
Unless of course…
First I admit I haven’t read this entire thread
Is there any reason why simply waiting for the state
of media_player.room
to become ‘paused
’ is not considered good enough?
I am using that method and it seems to work for me although admittedly I only have two uses of TTS so far so have not rigorously tested all cases.
I love the way you use the actual time length of the message in your script (it is very neat) but I can’t help thinking it is overkill. I must be wrong but can someone explain to me why?