Using GetVoice and parsing %voice for keywords

522 views
Skip to first unread message

Homer

unread,
May 29, 2013, 4:59:08 PM5/29/13
to tas...@googlegroups.com
Hi All,

I want to implement some home automation controls with tasker. Is there a way that I can use getvoice and parse the %voice variable for random combinations of the required keywords. For example,

turn light on
turn the light on please
turn on the light
please turn on the light

the keywords above would be "turn", "on" and "light".

I'm wondering if I can search %voice for the 3 keywords and then perform the action. Clearly "don't turn the light on" would also work but I'm assuming some user intelligence!

Thanks
Homer

easiuser

unread,
May 29, 2013, 6:10:44 PM5/29/13
to tas...@googlegroups.com
You can do it with pattern matching and if statements.

if %VOICE ~ *turn* then
  if %VOICE ~ "on" then
    if %VOICE ~ "light" then
       Turn on the light
    endif
  endif
endif

Watch out because *on* will match with combination automation and Ontario and the nested ifs can get messy. 

You might want to check out AutoVoice that is available on the playstore.  It builds a command structure from your voice input.

Homer

unread,
May 29, 2013, 6:40:26 PM5/29/13
to tas...@googlegroups.com
Hi Easiuser,

Thanks for your quick reply. I'm still getting to grips with tasker. Are you suggesting running this as a javascript? Otherwise, how do I create nested if...then statements? I've downloaded autovoice but couldn't see how this could help me? Sorry if i'm being dumb!

Thanks
Homer

cruise

unread,
May 29, 2013, 7:25:35 PM5/29/13
to tas...@googlegroups.com
If you want to do serious voice control like this in Tasker, I seriously recommend the AutoVoice plugin app. It basically handles all the heavy lifting of voice control for you, and just lets you trigger things off commands (or combinations of commands) in Tasker.

The full version is a (pretty cheap) pay for, but well worth it for anything big with voice activation.

nanobrain

unread,
May 29, 2013, 9:17:03 PM5/29/13
to tas...@googlegroups.com

easiuser

unread,
May 29, 2013, 9:46:46 PM5/29/13
to tas...@googlegroups.com
You can do all this through Tasker.  Might want to go through a tutorial.  There are many at the pocketables web site mentioned earlier for AutoVoice.

Pent

unread,
May 30, 2013, 2:13:42 AM5/30/13
to Tasker
If is an action in the Task category. There's also Else. It's simpler
with matching however, e.g.

Get Voice
If %VOICE Matches *turn*on*light*/*light*on*
Alert / Flash OK boss

See Pattern Matching in the userguide for matching help.

Pent

Homer

unread,
May 30, 2013, 5:42:04 AM5/30/13
to tas...@googlegroups.com
Hi Guys,

Thanks for all of your help - it's very much appreciated.

I downloaded AutoVoice but I couldn't see how it would help with this problem. As far as I could see, autovoice is useful for cascading voice commands but doesn't help me too much with my issue,

Pent - your suggestion works but get's more complicated when the name of a light is introduced. For example:

Turn on the dining room light                                on           dining   light

Turn on the light in the dining room                       on           light       dining

Turn the dining room light on                                dining      light       on

Turn the light on in the dining room                       light        on           dining

Turn the light in the dining room on                       light        dining   on

So my IF statement would need 5 combinations of "on", "dining" and "light". I was hoping there would be a search that could say something like:

if "on", "dining" and "light" are all present in "%VOICE" then blah, blah, blah..

Any ideas?

Thanks

Homer


joaomgcd

unread,
May 30, 2013, 5:51:02 AM5/30/13
to tas...@googlegroups.com
Your exact problem is described here: http://dominounlimited.blogspot.pt/2007/09/using-regex-for-matching-multiple-words.html

Regex is the answer :)

easiuser

unread,
May 30, 2013, 9:50:58 AM5/30/13
to tas...@googlegroups.com
Nice.  Thanks for the tip.

Homer

unread,
May 30, 2013, 10:08:09 AM5/30/13
to tas...@googlegroups.com
Thanks Joaomgcd - I'll take a look.

I've just changed my scheme and it seems to work well by doing the following:

* I have a shortcut on the home screen to a tasker Autovoice task
* I have an "Autovoice Recognised" profile that is used when Autovoice is activated.
* The Autovoice profile has a command filter of "lounge"
* I have set up another task called "turn on" that is called by the Autovoice profile, when the command filter "lounge" is part of the recognised speech.
* The turn on task is an IF statement, checking %avcomm for *on*light*/*light*on*

The above seems to work well - allowing me to use various combinations of sentence to turn the lounge light on. I can extend the "turn on" task to check for more conditions (turn off, dim etc) all called with respect to the lounge (as the lounge is the command filter that will only trigger the task).

Homer.
Reply all
Reply to author
Forward
0 new messages