Using Tasker with VoxCommando

From VoxCommando
Revision as of 11:25, 13 January 2021 by James (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If you have an Android device, you can use Tasker to send data from your mobile world to VoxCommando.

You can also easily send notifications from VoxCommando to Autoremote for Tasker.

This means that you can do things like generating VC events or TTS announcements based on activity that has occurred on your Android. You can even directly execute specific commands in VoxCommando (using VC.TellVox).

It's beyond scope for us to teach you how to use Tasker generally. The documentation below provides guidance on ways to communicate between Tasker and VC specifically.

Note: Most users should not need to use Tasker/AutoVoice just to use an Android as a VC microphone. If you think Google Now is working better than VoxWav, it's most likely because you have not set up VoxWav correctly or you're trying to talk into the mic with the phone an inch from your face. 

When set up properly, the accuracy of VoxWav is superior to Google Now because you will be taking advantage of VC's controlled grammar. VoxWav also has other useful features such as the ability to send touch commands. VoxWav has a customizable tilt on/off feature that can be run in the background, and should not interfere with your general phone usage if properly configured. Unlike Google Now, it does not require Internet access.

That said, you may still decide that you want to use Tasker/AutoVoice for other reasons.  Maybe you are already using AutoVoice or maybe you want to control VoxCommando when you are not connected to the same LAN as VoxCommando.

Send Messages from VC to Autoremote

Follow the Autoremote tutorial on how to send messages to Autoremote.

In VC, we always use the Scrape actions to send HTTP requests.

See the forum for a command example that works with Autoremote.

Tasker and AutoVoice as an Alternative to VoxWav

On your Android device, do the following.

  • Install Tasker.
  • Install AutoVoice.
  • Install UDP Sender.

Create a State Profile in Tasker

  • Open Tasker.
  • Go to Profiles -> Create a new Profile by clicking +.
  • Choose State -> Select State category Plugin.
  • Choose AutoVoice -> Recognized.
  • Click Configuration (pencil).
  • Click the checkmark (✔).
  • Then go back to State Edit (top left).

Create a Task

Simple Version (try this first)

  • Click + to add a new task.
  • Give your task a name.
  • Click + to add an action to your task.
  • Select Plugin -> UDP Sender.
  • Click Configuration.
    • For Destination IP, either enter 255.255.255.255 or specify the IP for the machine running VoxCommando.
    • For Port, enter 33000.
    • For Text field, enter vc.tellvox&&%avcommnofilter .
    • Click the checkmark (✔).

Advanced Version (more complicated, more likely to get a match)

  • Click + to add a new task.
  • Give your task a name.
  • Click + to add an action to your task.
  • Click Variables -> Variables Set.
    • Under Name, enter %vcmsg
    • Under To, enter %avcommsnofilter()
  • Go back to Task Edit.
  • Click + to add another action to your task.
  • Click Variables -> Variable Search Replace.
    • Under Variable, enter %vcmsg
    • Under Search, enter , (a comma)
    • Click the checkmark (✔) next to "Replace Matches".
    • In the Replace With field that appears, enter &&
  • Go back.
  • Click + to add an action to your task.
  • Select Plugin -> UDP Sender.
  • Click Configuration.
    • For Destination IP, either enter 255.255.255.255 or specify the IP for the machine running VoxCommando.
    • For Port, enter 33000.
    • For Text field, enter android.phrases&&%vcmsg .
    • Click the checkmark (✔).

AutoVoice

  • Go back until you're out of Tasker.
  • Launch AutoVoice.
  • Turn continuous mode on.

Make sure VoxCommando is running. Start issuing voice commands!

Allowing External Access

We have not determined whether this is necessary, but you may also want to:

  • Open Tasker.
  • Click Settings button on top-right corner.
  • Choose "Preferences".
  • On Misc tab, check "Allow External Access". (Depending on which version of Tasker you're using you may need to un-check "Beginner Mode" in the UI tab in order to access this setting.)

Other Methods to Send Notifications/Data from Tasker to VC

In VoxCommando

Enable the TCP plugin (if you haven't yet).

  • In the TCP plugin settings, enable the Simple Web Server. You can change the default port if that port is already being used by another application.
  • Save your settings. If you want to test the web server you've just created, click "Launch in Browser".
  • You will be sending HTTP get requests from Tasker to this web server.

In Tasker

It's up to you what kind of Android event you'll be using as a trigger (receiving a text message or email, a new notification of some kind, etc.).

What we care about here is the "Task" that you will be triggering within Tasker.

If you're more comfortable with IFTTT terminology: what we care about here is the That (i.e. the task). The Tasker "Profile" is the This. We leave the This to you to figure out.

Example: Generating an Event in VoxCommando

  • Create a new "Task" in Tasker. Call it what you like. (e.g. "Send event to VC")
  • Add a new "Action" to your Task.
  • From the "Select Action Category" menu, click on "Net".
  • Choose "HTTP Get".

Editing your HTTP Get Action in Tasker

  • In "Server:Port" enter the IP and port number for your VC computer that is running the web server, e.g. 192.168.0.1:8080 (Do *not* try to use 127.0.0.1, which simply means "localhost" in computerese. You need to know the correct IP address for your VC machine.)
  • In "Path", enter
/api/vc.triggerevent&&eventnameofyourchoosing&&optionalpayload

Et voilà. That's all you need to do in order to generate a custom event in VC. If you don't need to pass a payload, stop at the event name.

If you prefer a specific example:

/api/vc.triggerevent&&incomingSMS&&%SMSRN&&%SMSRB
Incomingmsg.png

When triggered on your Android, the above example will generate an event called "incomingSMS" in VC, which will show up in the history panel. It should include 2 payloads. (Caveat, these payload variables are untested: I'm basing them on Tasker's documentation, which you can consult for yourself.):

  1. Name of sender (represented by the Tasker variable %SMSRN)
  2. Message (represented by the Tasker variable %SMSRB)

As always, you can use this event to trigger any command in VC, and use the payloads in that command if desired.

To learn more about the format for sending various types of messages to VoxCommando, see the API page of the wiki. Generating events is just an example.

Alternatives to Tasker

The custom VoxWav apps for Android have some features that may meet your needs, without dealing with Tasker. For example, VoxWav automatically generates an event in VoxCommando when you receive a phone call on your Android. At the same time, it should mute the VoxWav mic.

The event will show up in the VC history panel as "Av.Ringing" and it includes as a payload the phone number that is calling. So, if you want to use that event to trigger a command that turns VC to off mode and displays the caller's phone number you could do something like this:

<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<command id="303" name="incoming call" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>VC.Off</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>Incoming call from: {1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>Av.Ringing</event>
</command>