You may have an awesome app that would benefit from hands-free control, and this ANE will let you provide that to your users. No button push is required, there is no Android dialog, and the voice recognition runs in the background similar to a Android service.
You can watch a video demo for Simmer, a hands-free recipe app I’m working on, to see the ANE in action. Also you can download the app and give me some feedback. Check it out y’all!
This ANE has been tested on the Samsung Galaxy Tab 10.1 and the Asus Transformer EeePad TF101, both with Android version 3.2.1 and AIR 3.1.
Here’s how to use the ANE:
- Download the Voice Commands ANE and the sample project.
- Start a new Flex Mobile Project.
- Name your project TestANEProject. Make sure the SDK is Flex 4.6.0.
- Under Mobile Settings, leave only Android checked as the Target Platform.
- Leave the default settings for Server Settings.
- In Build Paths, click the Native Extensions tab. Click Add ANE, browse to the location where you downloaded my ANE, select it and click OK. Click Finish to see your new project.
- The first thing you have to do is set the permissions for your new project, or Android won’t let the ANE function. Open TestANEProject-app.xml. Right-click it and open it with a text editor.
- The two permissions you need are INTERNET and AUDIO. Scroll down until you see this:
- Internet permissions are provided by default, so all you have to do is uncomment the RECORD_AUDIO permission. If it isn’t there, just add this line to the rest of the permissions:
Close TestANEProject-app.xml.
- Right-click TestANEProject inside the Project Explorer to open the context menu, and click Properties. Expand Flex Build Packaging and select Google Android.
- Click the Native Extensions tab and in the “Package” column make sure that checkbox is selected. If not, select it. It may tell you the ANE is not used in the application, and ask you if you want to include it anyway, say Yes. Click Apply, then OK.
- Almost there! Now you just have to add something to your app so you can see the ANE in action
Replace the contents of TestANEProjectHomeView.mxml with the following:
- Go ahead and run your app on any Android device running AIR 3.1. You will see that after you’ve spoken to the app, the ANE spits a comma-delimited string containing Google’s 5 best guesses as to what was said. Split the string and cycle through the resultant array of strings to evaluate the speech.
Tada! All done. Enjoy controlling your app with Voice Commands
- P.S.! With great power yada yada. Make sure you call stopListening() any time your app loses focus, or when you have no need for voice commands, otherwise Google’s voice recognition will continue in a loop in the background! We don’t want to eat up your precious device’s resources like that so turn the lights off when you’re not using em!
P.P.S. If you have any problems, just leave em in the comments section here. But do me a favor and use Logcat to see what might be going wrong and try to give me as much information as possible. You can email me the info at ruedaminute at gmail.
16bit ]]>
Please get in touch on Twitter (@ruedaminute) if you like the ANE, Simmer, or whatever. I’d love to collaborate and create some apps for fun and profit
Great extension! It’s inluded in my AIR for Android tech demo app – AIRexplorer
https://play.google.com/store/apps/details?id=air.AIRexplorer
Thank you!
Bravo for your extension!
It works remarkably.
I tested fine with version 3.2 of Android, but it seems it does not work with android 2.2.
can you confirm?
thanks.
Mourada
Ante,
very good application, very clean.
for your example, you use another extension, it seems to you?
does not solve my problem
thanks