Hello there, fellow Xamariners!
Been doing work on an app lately that implement Google's vocal recognition. Firstly, for anyone wanting to do this, I'm not doing it by using the built-in voice recognition intent which shows a popup I dont want to see. Instead I used CreateSpeechRecognizer to create my own speech recognizer. All this is done in the droid project via a concrete class called by the PCL with the DependencyService.
Everything works ok. By that, I mean that I hear a beep and can say out loud what I want to be recognized and the result is trapped by a custom class that implements IRecognitionListener. I implement the OnResults method of IRecognitionListener in order to have access the results of the recognition process. So the functionnality is there and everything's is great!
But..
The "problem" is that I wish to know if the app is currently in listening mode. I've created a property in my PCL interface called "isListening" that is implemented in the droid project. This property is set to true as soon as I call the StartListening method of the SpeechRecognizer. That way, if a recognition is currently taking place, I dont call StartListening over the one already there. Note that I think that the SpeechRecognizer created through CreateSpeechRecognizer can only stay alive for 4 seconds. Nevertheless I needed to check this.
Again everything is ok as long that there's something being recognized. Now, let's say that during the voice recognition session, I dont say anything, I wanted to make sure that when the speechrecognizer timed out I could set my property isListening to false.
I thought that by implementing the OnEndOfSpeech method of the listener (the class implementing IRecognitionListener) I could set the property there, but when I debuged, I've noticed that this method is called way before the speech (what I'm saying) is over. This method is called as soon as I StartListening. So in essence, as soon as I set the property to true, it is set to false a few milliseconds after that!
Looks like OnEndOfSpeech is not called at the end of the speech from what I see!
Did I missed something here ?
Thanks!