Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Android speech recognition service busy?

I use Android speech recognition service from my application.

It turns out that when two clients attempt to send requests at the same time (say, the user started one voice search from an app, then switched to another application while the search is still active, and launched another search), the service stops working.

Is there a way to determine that there's a voice recognition session in progress, so that I can refuse to start another one?

like image 759
gogabr Avatar asked Aug 24 '12 11:08

gogabr


1 Answers

You should probably be trapping ERROR_RECOGNIZER_BUSY in the onError handler:

@Override
public void onError(int error) {
  switch (error) {
    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
      // do something reasonable
    …
  }
}

You're most likely (only?) going to receive that on a request to start listening; unfortunately, I'm not aware of any way to test this condition without trying (e.g. I don't think you can pre-detect another process's listener being active to remove a microphone button)

(On stopping listening, you'd only get this error if you were trying to kill another process's listener somehow.)

like image 120
BRPocock Avatar answered Sep 23 '22 02:09

BRPocock