Public Sub StartListening(LANGUAGE As String, ONLY_RETURN_LANGUAGE_PREFERENCE As Boolean, PARTIAL_RESULTS As Boolean,PREFER_OFFLINE As Boolean) RecognizerIntent.Initialize("android.speech.action.RECOGNIZE_SPEECH",Null) RecognizerIntent.PutExtra("android.speech.extra.LANGUAGE_PREFERENCE",LANGUAGE) If ONLY_RETURN_LANGUAGE_PREFERENCE Then RecognizerIntent.PutExtra("android.speech.extra.ONLY_RETURN_LANGUAGE_PREFERENCE",LANGUAGE) RecognizerIntent.PutExtra("calling_package",Application.PackageName) RecognizerIntent.PutExtra("android.speech.extra.LANGUAGE_MODEL","free_form") RecognizerIntent.PutExtra("android.speech.extra.PARTIAL_RESULTS",PARTIAL_RESULTS) RecognizerIntent.PutExtra("android.speech.extra.PREFER_OFFLINE",PREFER_OFFLINE) If nosound Then Dim p As Phone volA = p.GetVolume(p.VOLUME_ALARM) volM = p.GetVolume(p.VOLUME_MUSIC) volN = p.GetVolume(p.VOLUME_NOTIFICATION) volR = p.GetVolume(p.VOLUME_RING) volS = p.GetVolume(p.VOLUME_SYSTEM) volV = p.GetVolume(p.VOLUME_VOICE_CALL) p.setVolume(p.VOLUME_ALARM, 0, False) ' p.setVolume(p.VOLUME_MUSIC, 0, False) - comment out to not stop music from playing p.setVolume(p.VOLUME_NOTIFICATION, 0, False) p.setVolume(p.VOLUME_RING, 0, False) p.setVolume(p.VOLUME_SYSTEM, 0, False) p.setVolume(p.VOLUME_VOICE_CALL, 0, False) End If JO.RunMethod("startListening",Array(RecognizerIntent)) End Sub
NoFor the "LANGUAGE" parameter, if I specify a null ("") string, will this just set the preferred language of the results to the devices default language?
Here is how you can get the user's device language.If not, how can I return results in the language of the user's device?
Sub Get_Language As String Dim jo As JavaObject Return jo.InitializeStatic("java.util.Locale").RunMethod("getDefault", Null) End Sub
Yes. Its possible. I will post an update today.Can an event be added to this library that will trigger when the device is fully ready and is now "listening" for speech?
(The BeginningofSpeech event is an event that triggers *after* someone starts talking - this is not what I am looking for)
What I am looking for is an event that triggers when the speech engine first starts to *listen*. I need such an event because on slower devices, especially when using the online mode, it may take a few seconds to fully initialize the SR engine before it's ready to start "hearing" words. So without this event (that I plan on displaying "Say Something" when this event triggers), the user may not know the SR engine is not yet listening and may miss the first couple of words the user said before it started to listen.