Rhasspy HTTP API tts with siteid

Hi,

I have a Server/Satellites rhasspy setup with version 2.5.5.
I am trying to send a TTS command to a specific satellite but I am not able to.

  • Server Config:
    Text to Speech: PicoTTS
    Language: Default
    Satellite siteIds: Kitchen

  • Satellite Config:
    siteId: Kitchen
    satellite

The test command: (To the Server IP)
ash-4.3# curl -X POST -d “hello” http://192.168.1.88:12101/api/text-to-speech?siteId=Kitchen
helloash-4.3#

Logs on the server:
[DEBUG:2020-09-03 16:38:45,737] rhasspyserver_hermes: Handling TtsSayFinished (topic=hermes/tts/sayFinished, id=2fe6fcdb-806b-4700-9b4b-3bf0a26caf1d)
[DEBUG:2020-09-03 16:38:44,770] rhasspyserver_hermes: Publishing 115 bytes(s) to hermes/tts/say
[DEBUG:2020-09-03 16:38:44,769] rhasspyserver_hermes: -> TtsSay(text=‘hello’, site_id=‘Kitchen’, lang=None, id=‘6743e68d-d023-42c9-9916-1aa10125bbf1’, session_id=’’)

Any idea what is missing? If I POST to the specific satellite IP without the Site ID it works

Thanks

Hi @jonaspaulo, welcome. This would work if you were using MQTT to connect your server and satellites, but HTTP only ever goes from satellite to server.

This happens because the server has no knowledge of the satellite IP addresses. With MQTT, the broker broadcasts to all connected clientd so the satellite can pick up the message and reach out to the server for TTS, etc.

Hi,

Thanks a lot for the feedback. I changed everything to my TLS Enable MQTT server and it is working seamlessly.

Great project!

Regards

1 Like

Just other question with siteId,

Can’t we also use playwav to do the same?

ash-4.3# curl -X POST “http://192.168.1.88:12101/api/play-wav?siteId=livingroom” -H “Content-Type: audio/wav” --data-binary @“alert.wav”
RuntimeError: No audio output system configured

Since the server has no audio output it isn’t forwarding the play wav to the client i guess.

Maybe I am missing something.

Thanks!

[EDIT] Nvm it works if we also set the audio play on the server to Hermes MQTT, although it doesn’t seem to close the stream since that after playing the wav it timeout:
ash-4.3# curl -X POST “http://192.168.1.88:12101/api/play-wav?siteId=livingroom,kitchen” -H “Content-Type: audio/wav” --data-binary @“alert.wav”

TimeoutError:

Ah, that’s interesting. The server can issue the play message over MQTT with the right site id, but it won’t hear the “done” message because it’s not subscribed to that same site id (livingroom).

One way to get around this is to POST to /api/mqtt/hermes/tts/say with a tts/say JSON message (siteId = livingroom). This will just put the MQTT message out and not wait for any kind of response. You can do this for all of the Hermes messages :slight_smile:

Ok I was able to do it for a sentence:

curl -X POST “http://192.168.1.88:12101/api/mqtt/hermes/tts/say” -H “Content-Type: application/json” -d ‘{“siteId”:“livingroom”,“text”:“hello”}’

But how to do it for a .wav file? Should I encode it in the json payload? and if yes calling which parameter? it seems that for tts/say the parameter is only a text:

Thanks again!

That would be the playBytes message. Unfortunately, that one won’t work through the HTTP interface yet because the MQTT payload is the (binary) WAV data instead of JSON. But you can send that message through MQTT directly at least.

Thanks. I will try through MQTT then. Just have to figure out how to get the binary WAV data to insert it on the wav_bytes: parameter.

@synesthesiam can you just provide an example using mqtt?

I am trying to use
topic: hermes/audioServer/livingroom/playBytes/fhsdf
{“wav_bytes”: “???”, “requestId”: “fhsdf”, “siteId”:“living room”}

But not sure what to input /how to convert my .wav file to wav_bytes.

Thanks!

In the payload of the mqtt message there is only wav_bytes since siteId and requestId are already present in the topic so the topic will be:
hermes/audioServer/siteId/playBytes/requestId
and the payload will be the raw bytes of the .wav file.
payload: RIFF $ WAVEfmt >} data ecc…

Yep also thought that it could take only the wav_bytes. Thanks for confirming.

How do I extract the raw bytes on linux from a xxx.wav file?
Also the .wav file has 1.1MB so maybe it is a lot of data to send on mqtt idk