No. You cant use this for continuous listening. Search for continuous speech recognition library.Hi, it’s a big library thanks!
How can I make listen all the time (without using a timer in sr_Results event)
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?
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.
Thank you for adding the "ReadyForSpeech" event so quickly - works great!Yes. Its possible. I will post an update today.
sorry and i will post in text next time,Please post error messages as text.
See the documentation of Phone.SetVolume. It will throw an exception if the device is in DnD mode. You can either catch this error or if it is important to set the volume, follow this path: https://www.b4x.com/android/forum/t...sturb-mode-programmatically.82794/post-524483