Voice Control (wit.ai) - My progress/setup + Tips/advice needed

I’m happy to, though not sure of the best way to attach a file. Let’s see if I figure it out before the end of the post :slight_smile:

The code is in two separate files, one to handle the rest communication with OH, and the other one that handles all the control logic. This last one is the main file, and I’ve currently called it publishable.py since I have stripped out my identifying entries :slight_smile:

I have four intents registered. One for simple lights which control, one for dimmer control, one for getting the status of any kind of device in any room, and want to verify if something is as expected (e.g. is the light in the living room on). This to last intents simply put the answer in a string item, and send a notification to me with this answer. I’m currently having some problems with the sendNotification OH, so I am looking into better ways of notifying.

The script basically takes anything after the script name on the command line and treats this as a whole sentence that needs to be recognised. This sentence is sent to api.ai, and I look at the received results. The intent determines which path they should take for building the command. The rest should be pretty self-explanatory, I think :wink:

Looking forward to hearing what you think, hopefully you have some other ideas than what I have had :slight_smile:

Turns out that Google Drive was the easiest: https://drive.google.com/folderview?id=0B9JghCRtpLV2MEU4X3JpQ1FxSVE&usp=sharing

I had some issues with addressing groups that contains other groups in the previous version of the script. An updated copy has been added to google Drive.

Hey there,

Do you have a public wit.ai model for openHAB?

Richard

Hi there I just don’t want to create another topic in Voice Control, but wanted to share my Idea.

I’m planning to use Google Now on Android phone + Autovoice App + Tasker. All these shall allow recognition of my speech with Google service and conversion of it to OpenHAB requests. For Communication with OpenHAB it should be possible to use REST API (directly from Tasker) or MQTT Plug-in (publishes into topics).

To extend the range of Android mic I want to try Bluetooth conference speakers, like Jabra Speak or something similar. The Android phone will be located in some hidden place, just waiting for “Okay, Google”. That’s it!
The only drawbacks I found so far is that I can not change “OK, Google” keyword to something else and that it should be learned - which might be a problem if I have more family members talking with my home…

this is my first result of voice enabled homeautomation with OK Google -> Auto Voice -> Tasker -> wit.ai -> openHAB
It’s the first time it feels like artificial inteligence - because with only minimal training it’s possible to speak different sentences for the same actions.
I use “bitte” as trigger word.
To control a single item I can say for example:
Esstisch einschalten
schalte Esstischlampe ein
Esstischampe anmachen
Esstischlampe heller/dunkler
Esstisch an

Even new untrained wordings are correct interpreted.

Do you use regular expressions in AutoVoice or set up a trigger on each combination? I started down that path but really don’t have enough use cases in my home to explore further.

That’s all done by wit.ai
I just entered my Itemnames and States in wit.ai and there is created the
CMD I pass to OH.

Rich Koshak bot@community.openhab.org schrieb am Do., 14. Apr. 2016,
21:52:

Hi Daniel

I’ve modified your script a bit because wit.ai will accept http gets with the bearer token in the url. Mine now looks this:

rule “Process Speech”
when
Item VoiceCommand received update
then
var String command = VoiceCommand.state.toString.toLowerCase
var String url = “https://api.wit.ai/message?v=20160415&q=” + command.encode(“UTF-8”) + “&access_token=TOKEN
var response = sendHttpGetRequest(url)
WitAi.sendCommand(response)
end

Means you can get rid of the script if you wanted!

Thanks.

Is this an undocumented feature? I couldn’t find it in the web API.

Sort of - they tell you how to call it via json and since it just translates it to a normal http request it was guessable :slight_smile:

Thanks for taking the time to publish your stuff. It really helped (I actually use the entities meta data to store the items names but it was really easy to take your code and make that change!)

Awesome, I’m really pleased this thread has benefitted others. Having said that I’ve put my voice control stuff on hold for the time being, I’m waiting for the necessary APIs to hit ESH so that proper bindings can hopefully be developed.

I have not integrated voice control yet into my system. But I would be a liar liar pants on fire if I said I haven’t already looked in to it.

I use IOS as my phone so I don’t have the voicecommand option. I also like the idea of not having to use my phone to make it work. So I have been looking into a couple of other projects that I may end up tying all together for my solution.

First is Jasper
http://jasperproject.github.io/documentation/usage/

In the usage example, you can see the system just listens till you say it’s name. It makes a beep to acknowledge it is listening now for the command.

I am looking at potentially using this to add some voice to my system by having this listen for commands, convert it to text, update the voicecommand item and then off to wit.ai to get the details and process.

The second was VoiceCommand
Same logic as above.

Both of these can also add in some benefits of being able to tie in to other systems like wolfram alpha, various computer controls, social media integration.

The 3rd project is here
That instructable shows how to setup a multiple microphone system. This is something I would like to tie in with jasper. This could be very interesting as you could have multiple microphones around that are able to hear your commands so you can go from room to room.

Outside of the multiple microphone thing, I have considered trying to find/buy/build an audio device that will take multiple microphone inputs and figure out which one has the best signal and dump the best signal to the voice command system. But I have not gotten this far, and assume there will be some hurdles.

Now again I have not actually done this. But I have put some research time in to some of these things. I do like to share my thoughts/findings I may even take this comment and put on my blog and elaborate.

Thanks guys! Hope this helps spark some thoughts!

2 Likes

I dunno anything about wit.ai, but for linux there is a nice program called Simon that uses open source voice recognition like Sphinx. It will soon be included in KDE, might already be in the newest version. If you can send the commands to the openhab system via the command line (which I assume is an easy thing to do), then you can just slap together some scripts for the things you want it to do, and have Simon run the scripts when you speak to it. There are lots of configuration options in Simon, might take a bit of messing around to set it up perfect, but it’s working very well for me to run programs, control Kodi, play music, select playlist, read news and so on. I’ll be testing it with openhab too as soon as I get all the openhab stuff configured and set up. Just be sure to have a good noise canceling mic, a program that filters out sounds coming from the computer/sounds system, and give it a name so it will know when to listen and when to ignore everything. That’s basically how I’m stopping it from listening to my conversations and start reading my RSS feed when someone says something like “I read in the news”.

Not super simple but not super difficult either. Probably the easiest thing to do would be to interact with the REST API using curl.

1 Like

Hi… i don’t understand how you parse the wit.ai responce… in tasker i presume and from tasker you invoke openhab ? Can you share your tasker project file ?

I use RESTask for the rest-call.
Then I use a Tasker JavaScriptlet in this way:
var ohitem = JSON.parse(rtres).outcomes[0].entities.Item[0].metadata
var ohstate = JSON.parse(rtres).outcomes[0].entities.State[0].value

1 Like

I ’ ll try … thanks.

Hi, wie kann man in restask eine variable übergeben? Also ich möchte den text aus google now über autovoice in eine variable in tasker laden (klappt schon!) und diese dann mit rastask nutzen um den text an wit.ai zu übergeben (klappt nicht mit variable, klappt bisher nur statisch mit GET oder POST).

Wie und wo muss ich in Tasker/Restask die Variable anhängen damit deren Inhalt an Wit.ai weitergereicht wird? Wäre prima wenn du da kurz mal eine genauere Beschreibung geben könntest.

I use the q-parameter in RESTask

oh, perfect! thanks man!