Send response from satellite somewhere else

Hi mates,

I wanted to try out making an wyoming satellite using a USB mic and a VM running Ubuntu on Proxmox.

That part went fine. I simply passed the USB device into the Ubuntu VM, installed wyoming-satellite, configured it and it’s working properly.

Now, I don’t have, nor want, a speaker connected to the system running the satellite. I’d rather have the response sent somewhere else (cough, old google home/nest). Send it to telegram, or a phone, or whatever.

Hence, I am looking for a way to grab the response of the voice command, save it as a variable end reuse it in another service.

But, how do I do that? I have been looking through the issues on the satellite github page, and in this forum. I thought that I somehow could grab the event, parse it somehow and grab the response, but I cant find what the event would be named.

In short, I would want an automation that listens for the response sent after a voice command from a specific wyoming satellite, grab the response and use it for another action.

1 Like

I had a similar need where I needed to output the text to a Sonos speaker, so I ended up creating a script within HA to process it, which is then invoked from the HA API. The text is passed via the Wyoming satellite using the --synthesize-command flag, as outlined in the documentation.

Once you define the path to the script and restart your service, you’ll have access to the text within the shell script, and then you can pass it to another service, or anything else you can dream of. Here is what my synthesized script looks like:

#!/usr/bin/env sh

text="$(cat)"
echo "Text to speech text: ${text}"

token='INPUT_TOKEN'

curlData='{
  "volume_level": 0.4,
  "target": "media_player.main_speaker",
  "message": "'$text'"
}';
echo "$curlData" | jq '.'

curl \
  -k \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $token" \
  -d "$curlData" \
  https://YOUR_IP:8123/api/services/script/wyoming_satellite_speak
1 Like

Amazing! Thank you for sharing!

What I did is based on your script, however I didn’t want to use tokens so I ended up using webhooks.

First. I am running one of my satellites in a docker container on an Ubuntu system, which has a mic.

When the response is sent to the satellite after an intent, I send that text as JSON to a webhook in an automation, which I then can do whatever I want with.

Script satellite-response.sh

#!/usr/bin/env sh
text="$(cat)"
webhookurl="https://192.168.0.11:8123/api/webhook/abc"
echo "Text to speech text: ${text} to $webhookurl"
json_payload='{ "response": "'"$text"'" }'
echo "Payload: ${json_payload}"
curl -k -X POST -H "Content-Type: application/json" -d "$json_payload" "$webhookurl" -v

Automation

alias: Satellite response
description: ""
trigger:
  - platform: webhook
    allowed_methods:
      - POST
      - PUT
    local_only: true
    webhook_id: "abc"
condition: []
action:
  - service: telegram_bot.send_message
    metadata: {}
    data:
      message: "{{ trigger.json.response }}"
      title: Smarto
  - service: tts.cloud_say
    data:
      entity_id: media_player.name
      cache: false
      message: "{{ trigger.json.response }}"
mode: single

1 Like

This is great - nice and simple. I’ve set it up similarly to output via a sonos device, but notice that while it does output correctly on the sonos, it’s also still outputting on the satellite speaker too.

Is there something necessary to tell the local speaker to skip playback?

@daytonturner

Did you find a way ?

Hey @droath

Can you please Share your Script in Home Assistant?

What did you enter under “Message” in the script?

Thank you very much

Yes he did. See: Added support to skip TTS playback by daytonturner · Pull Request #227 · rhasspy/wyoming-satellite · GitHub

1 Like

I’m sorry, but I’m feeling really stupid as I don’t underrstand what you are saying.

I’m running a raspberry pi as satellite and used following to achieve this: GitHub - rhasspy/wyoming-satellite: Remote voice satellite using Wyoming protocol

it is very unclear to me where you put the satellite-response.sh script

you put it on your satelite device? i fail to see how it is then triggered

You will want to have your script somewhere that the sattelite can reach.

Then you want to use the --synthesize-command when strating up wyoming_sattelite and give it the script as an argument.

Something like the below (see second to last command):

exec python3 -m wyoming_satellite \
    --name 'assist microphone' \
    --uri 'tcp://0.0.0.0:10700' \
    --mic-command 'arecord -r 16000 -c 1 -f S16_LE -t raw' \
    --snd-command-rate 16000 \
    --awake-wav "/usr/src/sounds/awake.wav" \
    --done-wav "/usr/src/sounds/done.wav" \
    --timer-finished-wav "/usr/src/sounds/timer_finished.wav" \
    --timer-finished-wav-repeat 3 0.75 \
    --mic-volume-multiplier 1 \
    --snd-volume-multiplier 1 \
    --mic-auto-gain 0 \
    --mic-noise-suppression 0 \
    --synthesize-command "/usr/src/scripts/synthesize.sh" \
    --no-zeroconf

I spent too much time to not help you out :smiley:

Ok first setup the wyoming-satellite (GitHub - rhasspy/wyoming-satellite: Remote voice satellite using Wyoming protocol) according to the install that is:

sudo apt-get update
sudo apt-get install --no-install-recommends  \
  git \
  python3-venv

Then

git clone https://github.com/rhasspy/wyoming-satellite.git

Then

cd wyoming-satellite/
python3 -m installer

Once configured run

python3 -m installer

again and stop the service.

Stay in the folder and use

nano synthesize.sh

Copy in the script to an editor of your choice and modiy your IP first.
Then open Home Assistant go to Automations and create new automation. Under “When” change it to webhook, it will prepolute with an ID. Adapt the script to match this.

#!/usr/bin/env sh
text="$(cat)"
webhookurl="https://192.168.1.100:8123/api/webhook/WebhookID"
echo "Text to speech text: ${text} to $webhookurl"
json_payload='{ "response": "'"$text"'" }'
echo "Payload: ${json_payload}"
curl -k -X POST -H "Content-Type: application/json" -d "$json_payload" "$webhookurl" -v

Now copy the script into your terminal and use Ctrl + X then “Y” to save it.
Let us make it executable by typing the following command. Adapt the USER_NAME to your actual login.

chmod +x /home/YOUR_USERNAME/wyoming-satellite/synthesize.sh

Now we need to adapt the way the satellite is starting up. We want it to utilize the synthesize script to also playback the answer.

First we need to find out the audio devices we are using.
Use the following command to find your microphone:

arecord -L

For me that’s “plughw:CARD=Webcam,DEV=0”

Equipped with this info we modify the satellite service using

sudo nano /etc/systemd/system/wyoming-satellite.service

There should be a line called ExecStart that we want to change. Note that this uses the remote wake work configured in Home Assistant → Assistant. Make sure to adapt the path with USER_NAME again. Also for the --mic-command specify your microphone excatly, that you got in the previous step.

[Service]
ExecStart=/home/USER_NAME/wyoming-satellite/script/run --name 'Pi Satellite' --uri 'tcp://0.0.0.0:10700' --mic-command 'arecord -D hw:3,0 -r 16000 -c 1 -f S16_LE -t raw' --snd-command 'aplay -D hw:0,0 -r 22050 -c 1 -f S16_LE -t raw' --synthesize-command "/home/USER_NAME/wyoming-satellite/synthesize.sh" --debug

Make sure that the service starts by executing

sudo systemctl daemon-reload
sudo systemctl restart wyoming-satellite.service
sudo systemctl status wyoming-satellite.service
sudo systemctl enable wyoming-satellite.service

This should now be reboot resistant. After a reboot make sure that its running:

sudo systemctl status wyoming-satellite.service

Back to the automation in Home Assistant. Configure the rest of the automation, like this:

[NEW USERS CAN ONLY EMBED A SINGLE GRAPHIC - REMOVED]

In order to not waste any ressources on the output on the satelite I configured an Assistant that uses no output. Don’t forget to add the wakeword in the three dots menu :slight_smile:

[NEW USERS CAN ONLY EMBED A SINGLE GRAPHIC - REMOVED]

Change the satellite config in the Integration:

[NEW USERS CAN ONLY EMBED A SINGLE GRAPHIC - REMOVED]

That’s it. Check the “Traces” section in the automation for troubleshooting if required. You can also test the webhook from your SSH connection on your PI by typing

echo "test" | /home/USER_NAME/wyoming-satellite/synthesize.sh

This should trigger the automation webhook if correctly configured.

Sorry for the formatting. I hope this is helpful!

I’d prefer to do it in a single post… but hey… Maybe a mod can fix it :slight_smile:

Hi, how did you made to mute the wyoming satelite locally?

I created a special assistant in the Assistant menu and simply removed text-to-speech like this:

Good luck!