Possible to trigger voice control "listen" via commandline, script, or rule without app?

Platform information:

Hardware:
Raspberry Pi 4b 4GB

OS:
openHABian: Stable track 4.0.4 Release Build

Java Runtime Environment:
openjdk version “17.0.9” 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Debian-1deb11u1, mixed mode, sharing)

Configuration:
Built-in Interpreter enabled
Using HabPanel

Issue of the topic:
Is it possible to trigger listening for voice control via commandline, script, or rule without an app?

Voice control works well in HabPanel (click the Speak icon on the upper right), but searching around I haven’t been able to find a way to trigger “listen” any way other than the HabPanel icon (e.g. via commandline, http/curl, script or rule). Perhaps I’ve been searching for the wrong terms.

I know the app has a button, and I know about Rustpotter and keyword, but it would be handy to be able to have the flexibility to trigger/call voice control listening mode as a widget and rule. Is this possible?

Thank you!

Hello,

Yes it is possible with actions, see vocal assistant actions.

“Listening” takes place where the microphone lives. You will not, for example, be able to trigger listening on your phone from the command line, rule, or anything else running on the openHAB server. You’ll need to trigger that listening on your phone.

If your OH server has a microphone attached, then yes, I’m sure you can trigger the listening on the OH server, but it’s only going to be listening on that one microphone connected to the server.

Hello!

Thanks for putting me on the right track!

Best!

Thanks, Rich!

I don’t have a mic on my Pi to test, but I’m assuming that when I use “javasound” as the audio source it’s looking for the mic over there as you outlined (and why I get this error).

[WARN ] [.core.voice.internal.DialogProcessor] - Encountered audio error: Error creating the audio input stream: No line matching interface TargetDataLine supporting format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian is supported.

Here is the test rule I used.

rule "Test 1 Trigger"
	when
		Item TestTriggerSwitch changed
	then
		say("Ready") ;
                startDialog("javasound", "webaudio", "system", "voskstt" ) ;
                stopDialog("javasound")
  end

This (server side listening) has possibilities, but I was wondering if would be possible to basically mimic the “speak” button in HabPanel that would use the triggering device’s mic? When I click the “speak” button from my laptop (using a browser HabPanel instance), my laptop’s mic listens.

Thanks again!

You’ll have to figure out how to do that on the device itself. From a privacy perspective, software that activates your device’s microphone without your interaction is a really bad idea.

Understood and appreciated! I’m guessing the way HabPanel gets around that is it’s piping (perhaps not the right term) the request through the server back to the browser. Going through HabPanel via a Widget button would be fine–I’d be able to resize and move it as opposed to the fixed floating speech button option there.

I tried to copy and paste HabPanel’s html code into a template widget hoping I could isolate the speak code and HabPanel locked up and refused to load! Oh boy! LOL

Really bad idea! I had to restore from a backup. LOL

Happy New Year!

HABPanel runs in the browser on the current in the first place. It asks for the microphone locally.

I guess my quest is now how to trigger/call the microphone locally so OpenHab’s interpreter gets it.

Thanks again, Rich!