TTS via Rhasspy and REST API (solved)

Hi, I’ve installed Rhasspy on my HassOS-Hass.io Raspberry Pi configuration, and it works fine in one direction, but not in the other. That means, I can say commands like “turn the lights on” but it would be even nicer if I could ask questions like “what is the time?” and get it talked back to me. Ideally via Rhasspy or an offline TTS system (I don’t want to send all my queries to the google or amazon servers).

I can type commands in rhasspy and have them read out to me, which means that the pre-installed picotts works! I only don’t understand how to send a command from hass to rhasspy in order to say it. Any ideas?

1 Like

You need to create another Home Assistant service that handles text-to-speech with a variable payload of whatever text is necessary.

A little further up the thread, look for the REST command definition:

rest_command:
  rhasspy_speak:
    url: '192.168.1.nn:12101/api/text-to-speech'
    method: 'POST'
    payload: '{{ payload }}'
    content-type: 'text/plain'
1 Like

Hi, i tried to enter this in the configuration yaml

rest_command:
  rhasspy_speak:
    url: 192.168.0.28:12101/api/text-to-speech
    method: POST
    payload: 'hello world'
    content_type: 'text/plain'

Nothing happens (the log in rhasspy does not react)

However, if I use postman to post to the same URL, rhasspy does respond, by reading out ‘Hello World’ and adding the lines to the log.

What did I forget? A comma, a quotation mark? Do I need to enable REST in homeassistant? Can I test it at another API?

THis doesn’t work either:


rest_command:
  rhasspy_speak:
    method: POST
    url: '192.168.0.28:12101/api/text-to-speech'
    content_type: 'text/plain'
    payload: 'hello world'

Was a simple mistake. Didn’t write http:// because it was not needed in postman, but it is required in hass. Working code is:

rest_command:
  rhasspy_speak:
    url: http://192.168.0.28:12101/api/text-to-speech
    method: POST
    headers:
      content_type: 'text/plain'
    payload: 'hello world'
1 Like

Last question: If anybody can help me send the current time to my TTS system, that would be amazing. I understand there is a now().hour command, but if I change my payload from ‘hello world’ to ‘now().hour’ it just reads the command, not the time. Again, am I missing some brackets or what?

{{ now() }}
{{ now().hour }}
{{ now().minute }}

when entered in the Developer Tools / Template Editor screen displays

2020-01-19 14:40:12.807660-05:00
14
40

I believe you’d need to use the template syntax to make this work:

  - data_template:
      payload: {{ now() }}

Is it possible to have more than one voice assistant (with a speaker & mic) connected to the homeassistant? How would that configuration look like under the tts? hassio reply back to all connected devices?

In my configuration, I have Rhasspy “server” running on the Home Assistant host in a separate Docker container. Then there are two Rhasspy “client” (satellite) systems running on RPi3B+ systems in other rooms of the house. The “server” install takes care of audio processing and intent recognition, and talking to Home Assistant. The “client” satellite installs simply listen for wakewords and send data to the “server”.

@FredTheFrog Can you direct me to the docs where I could install the Satellites? Can’t say I have searched thoroughly but didn;t see any instructions to setup just the client

I don’t know if there’s new doc in the 2.5 version upcoming. There wasn’t really anything in the older documentation, if I remember correctly. Essentially, you don’t use intent recognition or audio processing on the satellites, only wakeword recognition. Then the satellites send/forward their audio to the server/host instance of Rhasspy for voice and intent recognition.

thanks I was assuming the same. How do I get hold of 2.5? I don’t see any option or release in github

Let me know what you find @manju-rn - I’m also interested

You can use the 2.5 pre-release version, it has a satellite support. See this thread for the links

1 Like

How can I specify the device that plays my audio using this POST call ?. Suppose I have a speaker configured in HA or I have browser that I wish to specify as the audio sink how do i do that ?