Categories
Flex

Speech Recognition ANE – Source



As a follow on for the Speech Recognition ANE I put up for download a while back, here is the a post to give out the source files.

The source can be downloaded from my BitBucket repository.

If you are looking for the compiled ANE instead, click here

The contents of the zip archive are,

  • Android Native Project
  • Actionscript Library Project
  • Files required for compilation


The Library is responsible for creating a bridge between Actionscript and Native code. The code written here is also the entry point for APIs exposed by the ANE. Library and Native Projects are fairly descriptive and appropriately commented. I will just go through things that need to be in place to get this compiled.

If you just want to go ahead and try compilation, skip to the 5th step

  • Import project listed under Android Native Project into a preferred IDE and export a JAR
  • Import project listed under Actionscript Library Project into Flash Builder and export a SWC
  • Notice the organization of files in the Files required for compilation directory. Replace JAR, SWC and extension.xml files in the appropriate directories with the one’s you just exported
  • Without disturbing what you have already done, rename SpeechLibrary.swc to SpeechLibrary.zip and extract the library.swf file. Replace the one in Files required for compilation/NativeAndroid, with this.
  • Open Files required for compilation/compile.bat in your favorite text editor. Going forward, I will be referring only to the Windows platform. For MAC, please read this document
  • Customize attributes for ‘root_directory’ and ‘signing_options’ (Namely, CERTIFICATE_PATH – a P12 file and CERTIFICATE_PASSWORD)
  • Exit editor, and run the compile.bat file to generate an ANE file !

That is as easy as it gets to generate an ANE file !

Feel free to make changes to the source and experiment. If you do extend the source, say make it iOS compatible, I’d be happy to link up here!

Here is another great resource you must have a look at before building native extensions, http://www.adobe.com/devnet/air/articles/developing-native-extensions-air.html

New ActionScript Native Extension - Speech Recognition

By Immanuel Noel

A techie at heart. Works with Adobe at Bangalore, India. Currently do DevOps. Been a part of the ColdFusion Engineering, Flash Runtime Engineering, Flash Builder Engineering teams in the past. Was a Flash Platform Evangelist, evangelizing the Adobe Flex platform. Spoke at numerous ColdFusion / Flash and Flex tech conferences. This blog is a collection of some of my strides with technology.

More on me on the home page

19 replies on “Speech Recognition ANE – Source”

Hi Immanuel,

Well, remember I told you I converted the code to return the entire list of results? Well, I thought it worked only to realize it does not. 🙁

In the SpeechHandler class:
I could not find how to pass the matches ArrayList to the speechContext dispatch method, so I simply concatenated the strings, comma delimited, and returned it as string to the speechContext.dispatchStatusEventAsync method.
Doing it like this did not require any other changes to the Android native or AS3 library projects, since String is still being returned.

I then packaged the ANE again as per your instructions above, replacing only the new JAR.
But when I use the newly packaged ANE in my project, I still get only one result, not a comma delimited list…

What am I missing?

Also, is there a way to debug the native extension code while debugging the Air for android project that uses it?

Thanks so much for your help!
Sefi

Immanuel,

Nevermind, I found it, in the SpeechInit EXTRA_MAX_RESULTS definition! Duh! 🙂

Still would be glad to know if you know of a way to debug the ANE code from the running app.

Sefi

There is only one thing that would make this better…charge money for it! We need a functioning marketplace for ANE’s or they just won’t be as plentiful as needed.

Thanks for making it available…just saying, it would be nice if it put a few hundred or even a few thousand dollars in your pocket…that might enough to have created a few more 🙂

Not so quick question. What best practices can you share when trying to access R. resources? I thought using a line like R.layout.somelayout wasn’t allowed or am I wrong? I had a MapActivity that I was trying to use for Google Maps but abandoned this route. Instead, I’m trying to use the WebView and Javascript v3 to display a Google Map but I can’t launch any Activity that must point to a resource (R.layout….R.id….). The suggested method for accessing resources ( context.getResourceId ) doesn’t seem to work.

Thanks for your input!

Markus

Sorry for the double post. What are the rules for accessing an Android resource using Native Extensions. I see that you are using the R.layout syntax and I thought that was a no no. Could elaborate on how best to approach accessing Android resources with ANE?

Thanks,

sorry for the double post question…

Markus

Hello Immanuel!

Thank you a lot for releasing the source code for this extension. I’m building an extension too (for bluetooth usage) and was having a problem when I had to get the result of an activity that was started by an Intent. I couldn’t find anywhere the solution so I temporarily stopped developing the extension (I tried to learn native android app development to understand how it worked better but couldn’t find the time). I just realized that you released the source, so now I found a very elegant solution to what I was trying to do. Thanks a lot!

Hello

Can any one tell me that can I develop native extension on windowsOS for iOS devices.

Thanks in Advance.

hi,
gr8 job on the ANE.
could you plz tell me if the sample project uploaded
is compatible with flash builder 4.5.1 .
I’m facing build errors like
__________________________________________
Errors occurred during the build.
Errors running builder ‘Flex’ on project ‘SpeechMobile_2’.
java.lang.NullPointerException
Errors running builder ‘AIR application.xml Builder’ on project ‘SpeechMobile_2’.
java.lang.NullPointerException
———————————————

thanx

@raag1, this is a known error. Occurs when the libraries aren’t linked up correctly.
Others have had the same problem in the past. Could you please browse through the comment stream?

[…] new-actionscript-native-extension-speech-recognition : an API to launch the default speech recognition UI and capture voice input. also speech-recognition-ane-source […]

2 questions:
————
1. When I open the Android Native Project in java/eclipse IDE, I get 2 errors: (a) “The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project”
(b) “The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files”

Do these need to be resolved before I can create a complete .jar? If so, what do I need to do to resolve these?

2. When looking thru your code, it talks about opening the normal Android speech input UI. I do not want the UI, I want the ANE to run in the background (w/no UI) listening for simple commands: like open, close, etc. How do I do that w/your code?

Thanks in advance!
Tom S.

Hi,

Thanks for your work !
Do you plan interesting yourself at the new feature allowing us to use recognition when off-line ?

Thx a lot again for sharing your work and explanations

Leave a Reply

Your email address will not be published. Required fields are marked *