Android Question CRGoogVR-Library, Google Voice Recog w/ source

canalrun

Well-Known Member
Licensed User
I've uploaded an example B4A app for Google Voice Recognition along with its source code and Eclipse Java source code for the CRGoogVR library I developed.

https://www.dropbox.com/s/ax0nzxf7v1rzsy1/CRGoogVR.zip?dl=0

I've also included my compiled APK so you can just quickly install and try out the example app, if you want.

I placed everything in a zip archive and uploaded to Dropbox - the zip file is likely too large to upload directly to the forum.

To build the CRGoogVR library I used the Simple Library Compiler (SLC) available elsewhere on these forums.

I use Eclipse mainly to take advantage of the IDE editor, Project structure, syntax checking, and tips, but it was not used to build the library. The library was actually built using the SLC.

upload_2017-2-24_19-59-29.png



When I run the SLC, a window similar to the above opens. The string in A points to the Eclipse Project workspace directory for the CRGoogVR library on my computer. The text field B points to where the compiled .jar and .xml files will be placed. I don't know what C does or where the string in this field came from :D.

Unless you want to make changes and compile the library, you can just:
  1. Use the Dropbox link above to download the zip file and extract the B4A code into a B4A project directory.
  2. Copy the CRGoogVR .jar and .xml files to your B4A additional libraries folder.
  3. Compile the B4A app.
  4. (or just install the included APK to your phone).
I'm still using version 4.30 of B4A so you might see a warning when you open the B4A example with a later version. Everything should work, however.

Here's a screenshot of the executing demo B4A app.

upload_2017-2-24_20-7-38.png


  • Click on the Start button and wait for the green "recording" status message. The default Google Speech Input dialog is not displayed.
  • The microphone will capture audio, send it to the Google Speech Recognition API, and the text VR is shown.
  • End of speech will be automatically detected, but you can use the Stop button to end things early.
  • Both interim partial results (pre-pended with PR: ) and the final result (pre-pended with FR: ) are displayed.
  • The Rectangular field toward the upper right will show the microphone RMS value.
This library is similar to my CRBingVR library, but uses the Google Speech API rather than the Microsoft Cognitive Services speech API.

I think the Microsoft API recognizes speech a little better, but the Google API does not require an account or "Key" (or charge a fee) to use their API.

Barry.
 

Attachments

  • upload_2017-2-24_20-7-4.png
    upload_2017-2-24_20-7-4.png
    31.3 KB · Views: 319
Last edited:

canalrun

Well-Known Member
Licensed User
As far as I can tell the Google version (CRGoogVR, actually uses the Android API) does not allow you to send audio data – that would include wave files, data captured directly from the microphone, or some other streaming audio source.

It handles the audio input from the microphone, detecting start/stop of speech, no-speech-detected, and I believe does noise suppression.

Barry.
 
Upvote 0

Syd Wright

Well-Known Member
Licensed User
Nice job. It is apparently not possible to change the recognition language and it does not offer continuous speech recognition (whereas CRBingVR3 does, but allas not in Dutch (yet)).

Your library seems to use the regular (free) Google API/SDK that is part of Android.
However, like Microsoft Bing, there also is a paid Google SR API version. It would be nice if someone could develop a library for that.
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Special thanks to Barry (CanalRun) for these libraries :)
Using them with B4a Version 8.8 and the new Google/Android requirements I have made it work with:
1. Include the RuntimePermissions library
2. Update the manifest to:
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
...
AddPermission(android.permission.RECORD_AUDIO)
AddPermission(android.permission.INTERNET)

3. Code
B4X:
Sub Activity_Create
...
RequestPermissions
...
End Sub

Sub RequestPermissions
    ToastMessageShow("Requesting permissions", False)
   rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO)
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    If Permission = rp.PERMISSION_RECORD_AUDIO Then
        CRGVR.Initialize("CRGVR")
    End If
End Sub
Thanks Barry!
 
Upvote 0
Top