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
19 replies on “Speech Recognition ANE – Source”
[…] UPDATE 19/02/2012 —- Source for the ANE is posted below, http://blog.immanuelnoel.com/2012/02/19/speech-recognition-ane-source/ :ActionScript, Actionscript Native Extensions, Adobe, AIR, ANE, Flash Builder 4.6, Flex, Mobile, […]
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
@Sefi.. Working around with a comma separated string must work. Just ensure you have the set the EXTRA_MAX_RESULTS property to greater than one in the SpeechInit.java file.
Also the only way to debug is to trace statements written onto the console using a connected LogCat
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
Cool, thanks.
I’ll check the log facility.
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 🙂
Thanks Mark! But the resource most constrained for me, is time ! 🙂
Worth mentioning, a repository, http://extensionsforair.com/, already exists out there, and it is being populated with newer ANEs regularly. Do check it out.
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.
[…] new-actionscript-native-extension-speech-recognition : an API to launch the default speech recognition UI and capture voice input. also speech-recognition-ane-source […]
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
@serge
That’s in the books. But i’m unable to find time to work on offline recognition! 🙂