Hi,
I’ve setup a Rhasspy installation and was wondering if it is possible to simply send the “output text” (the STT output) of rhasspy as an input to HABot (like what I would type in the chat field).
I found the solution with the following:
In Rhasspy Settings, I do not recommend to set the MQTT broker as your main openHAB one, as the audio stream goes through it (since Rhasspy 2.5). I am using a single setup, so have the Rhasspy MQTT “internal” broker. This broker runs in Rhasspy Docker (unless it is not installed with docker). In order for openHAB to be able to connect to the Thasspy MQTT broker, the docker settings must expose the MQTT port 12183:
docker run -d -p 12101:12101 -p 12183:12183 \
--name rhasspy \
...
Within openHAB, I created a MQTT broker connection to the Rhasspy MQTT broker (no username/password, so somewhat unsafe):
I am catching the Rhasspy command through the MQTT messages:
things:
// Rhasspy
Thing mqtt:topic:rhasspy "Rhasspy MQTT" (mqtt:broker:rhasspy) {
Channels:
Type string : wakeword "Wakeword [%s]" [ stateTopic="hermes/asr/toggleOn", transformationPattern="JSONPATH:$.reason" ]
Type string : transcription "STT [%s]" [ stateTopic="hermes/asr/textCaptured", transformationPattern="JSONPATH:$.text" ]
}
items:
// Rhasspy
Group gRhasspy "Rhasspy" <recorder> (gAll)
String Wakeword "Rhasspy Wakeword [%s]" <recorder> (gRhasspy) {channel="mqtt:topic:rhasspy:wakeword"}
String VoiceCommand "Rhasspy STT [%s]" (gRhasspy) {channel="mqtt:topic:rhasspy:transcription"}
String HABotResponse "HABot Response [%s]" <recorder> (gRhasspy)
And this is the rule:
rule "VoiceCommand"
when
Item VoiceCommand received update
then
//define HTTP REST POST request
var url = "http://YOUR.IP.OF.OPENHAB:8080/rest/habot/chat"
var contenttype = "text/plain"
var String POSTrequest = VoiceCommand.state.toString
//send the request
var output = sendHttpPostRequest(url, contenttype, POSTrequest)
// log response (JSON)
logInfo("HABot Chat:", output);
// transform response
var String response = transform("JSONPATH", "$.answer", output)
logInfo("HABot answer", response)
postUpdate(HABotResponse, response)
end
Have fun!
Edit: Since Rhasspy 2.5, the mqtt server has been changed and I have updated the explanation.