Handling RecognitionListener Errors

前端 未结 4 1243
旧时难觅i
旧时难觅i 2021-01-03 03:29

I am using the Android\'s speech API to continuously getting input from the user. However this doesn\'t work quite well when errors occur.

What I do is restarting th

相关标签:
4条回答
  • 2021-01-03 04:05

    I m posting this late , but this might help some one. I was also facing same error , & also it was not listening after some random time , i tried the following & it helped me somewhat, Try doing this ,

    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY: 
            recognizer.destroy();
            startSR(); // As it destroys the current objects & calling startSR() will instantiate
                       // objects again 
    
    0 讨论(0)
  • 2021-01-03 04:08
    Intent RC = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    
            if (!RC.hasExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE))
            { 
                RC.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.dummy");
            } 
    
            sr.startListening(RC);
    
    0 讨论(0)
  • 2021-01-03 04:09
    • If you get recognizer busy error you have to call cancel and then call startListening
    • If you get server or network errors you have to check for network connection before calling startListening
    0 讨论(0)
  • 2021-01-03 04:20

    Try to properly clean up after the error, e.g. call cancel or destroy on the SpeechRecognizer.

    0 讨论(0)
提交回复
热议问题