Integrate snips.speech/say with ha.service.tts


#1

First of all, thanks for integrating snips with HA. I use it on a daily basis and really appreciate it.

I’ve setup HA to output TTS over my sonos system, lower the volume on hotword detection, etc… I use the speaker on my snips satelites only for start/end beeps to know that snips started listenning or is finished.
Right now I have two systems for speech output. Snips -> local speaker and HA -> service.tts ->Sonos

What I would like to achieve is, to integrate snips and HA so that when Snips says something (e.g. asks me if it should close the garage door) it triggers the ha.service.tts which is then beeing played via my sonos instead of having snips speak via the locally attached speaker.

Has anyone allready done this, and if yes, could point me in the right direction?
@tschmidty could this be added to the component configuration? Maybe something like
speechService: service.script.sayViaSonos | service.tts.google_say?


#2

Hmm, can you just use blank text for your response and then call the tts yourself in the intent scripts?

Alternatively if you wanted all of your tts to go through sonos, you could set up a custom tts provider on snips. Here is what you would use in snips.toml and the script from the hassio addon to set the custom provider

provider = "customtts"
customtts = { command = ["/usr/bin/customtts.sh", "%%OUTPUT_FILE%%", "${LANG}", "%%TEXT%%"] }

Then modify this and put it in /usr/bin and chmod +x it on your snips machine. This use the tts service to generate text and play it on the snips machine but you can modify it to call the sonos tts service also. I modified it a bit but zero testing so you will need to tweak it.

#!/bin/bash

#set -x
API_KEY="$YOUR_KEY_HERE"
FILE="$1"
LANG="$2"
TEXT="$3"

MESSAGE="\"{\\\"message\\\": \\\"${TEXT}\\\", \\\"entity_id\\\": \\\"tts_sonos\\\"}\""
echo "${MESSAGE}"

RESPONSE=$(eval curl -s  -d "${MESSAGE}" -H \"Authorization: Bearer "${API_KEY}"\" -H \"Type: application/json\" http://hassio/homeassistant/tts/sonos_say)
if [ -z "${RESPONSE}" ]; then
    exit 1
fi
echo "${RESPONSE}"

#3

Thank you for you fast and extensive answer.
Sure I could handle the TTS within HA, that’s what I’m allready doing. And it works like a charm.

What I meant is the part where e.g. a slot is required and I define a question within the snips console where snips ask for the missing slot information or where you intiate a query from HA. From my understanding this is beeing played through the local snips tts.
Sorry if I was not clear enough on this. I will take a look at what you proposed with setting a custom tts as this seems what I am seeking for.

Thank you so much for your help!

Cheers
Kraken