Rhasspy won't speak

I have this in home assistant configuration.yaml:

rest_command:
  rhasspy_speak:
    url: 'http://192.168.0.130:12101/api/text-to-speech'
    method: 'POST'
    content_type: 'text/plain'
    payload: "{{ payload }}"

The IP address is correct. I have this in an automation:

service: rest_command.rhasspy_speak
data:
  payload_template: >-
    Today is {{ now().strftime("%A") }} the {{ now().strftime("%-d")}} {{
    now().strftime("%B") }} {{ now().strftime("%y") }}

The action is triggered by a rhasspy sentence and produces this trace:

Executed: July 14, 2022 at 17:49:53
Result:
params:
  domain: rest_command
  service: rhasspy_speak
  service_data:
    payload_template: Today is Thursday the 14 July 2022
  target: {}
running_script: false
limit: 10

The trace shows that the payload was sent to rhasspy, but the payload is not spoken by rhasspy. If I paste the payload into the NanoTTS Speak field, rhasspy will say the sentence. Where is this going wrong? Thanks for any help.

Try this

rest_command:
  rhasspy_speak:
    url: http://192.168.0.130:12101/api/text-to-speech
    method: POST
    headers:
      content_type: 'text/plain'
    payload: '{{ payload }}'

Pasted this and restarted HA but no joy. I also tried placing single quotes around everything except POST, but that didn’t work either.

Why don’t you try and see if just text will work? The rest_command I showed you is what I have in my HA (with my IP obviously). My URL and method don’t have any quotes. Also, long shot, but I’ve had issues with quotes copied and pasted from the internet. Might want to check to make sure the single quotes are indeed single quotes.

rest_command:
  rhasspy_speak:
    url: http://10.0.0.XXX:12101/api/text-to-speech
    method: POST
    headers:
      content_type: 'text/plain'
    payload: '{{ payload }}'

Good idea. I found that this works as a rhasspy speak action, saying “hello world”:

service: rest_command.rhasspy_speak
data:
  payload: hello world

But this does not, with rhasspy remaining silent:

service: rest_command.rhasspy_speak
data:
  payload_template: "hello world"

I guess I should take this over to the HA community. Thanks for the help.

I found out that the data needs to be marked as the template, not the payload. This works:

service: rest_command.rhasspy_speak
data_template:
  payload: >
    Today is {{ now().strftime("%A") }} {{ now().strftime("%-d")}} {{
    now().strftime("%B") }} twenty {{ now().strftime("%y") }}

I’ve marked your last entry as the solution since it led me in the right direction.

This is not correct, I am not using the rest command anymore, but you should use this:

service: rest_command.rhasspy_speak
data_template:
  payload: >-
    Today is {{ now().strftime("%A") }} the {{ now().strftime("%-d")}} {{
    now().strftime("%B") }} {{ now().strftime("%y") }}

Because the data you are sending to the command is called “payload”. It might be a bit confusing.

See this old example:

Thanks; I think you posted just about the time I found that out. One question, though; why use > and a dash after payload. The > alone works.

o ok, cool. Probably because when I started some did it like that and I never tried otherwise :slight_smile: