Do you dream about picking up your phone and sending voice commands to your hardware?
Well, dream no more.
In this article I will explain how I talk to my projects, and you can easily do the same*.
* As long as you have an Android device.
If you know how to do this in iOS (ie using an iPhone) please leave me a note below.
The project I will use as example will be my Garage Commander.How it works
In a nutshell, we will speak the magic words "Ok Google" or tap on the microphone of the Google app so our phone goes in listening mode. Once we say something (example "open garage"), we will intercept the voice command and send an HTTP request to our hardware.
In this particular example the HTTP request will be sent to the Particle Cloud api, but if you have other hardware and they can receive HTTP requests, you are in business.Installation
For sending commands to our projects we will need three apps:
Google Now is free, Tasker and Autovoice are paid apps. However both have 7 days trials, so you can try them all you like before having to decide to pay for them.
Go ahead and install the three required apps in your phone.Configuration of Tasker
In Tasker we need to create a task and a profile.
The task will send an HTTP request and the profile will be the "thing" (for the lack of a more appropriate term) that we can call from Autovoice.
Let's create the task. Open the Tasker app and:
- create a new Task called "OpenGarage"
- add an Action
- select Net
- select HTTP Post
- enter in Server:Port
https://api.particle.io/v1/devices/<PARTICLE DEVICE ID>/garage_open
- enter in Data/File
access_token=<YOUR PARTICLE ACCESS TOKEN>
Please note that garage_open is the function we want to trigger with this POST request. For more info on the functions available remember to check the particle code in the example project.
Here are some screenshots to guide you:
If you get stuck, visit this thread for some help or leave me a note below.
Now let's create the profile in Tasker. This is the thing that we will trigger when we say "open garage". Here is what you need to do:
- create a new Profile
- select Event
- select Plugin
- select Autovoice -> Recognized
- tap on Configuration
- tap on Speak Filter
- record your voice command (say open garage)
- choose your voice command from the list (open garage)
- hit the check at the top then hit back in Tasker
- select the task you want this command to trigger, it should be OpenGarage
- you are done!
You can also follow the instructions on the video in the Google Play page.Test it
Now say "Ok Google" or tap your Google app.
Say "open garage". Autovoice will intercept this voice command and will trigger the Tasker task that will send an HTTP request to open the garage, or do whatever you want in your hardware!
Here is a video to give you an idea:That's it
For concrete examples of this article, take a closer look at my Garage Commander project.
If something is not clear, please leave me a note below.
PS: there are other ways of achieving the same thing. If doing your own app sounds like your cup of coffee, have a look at this pretty interesting project, by Paul Scott.