SpeechRecognizer doesn't timeout when silent

主宰稳场 提交于 2019-12-24 11:00:14

问题


With the recent Google App update (6.14.20.21.arm), the google Speech recognizer stopped working. If you respond within seconds after the recognizer is started , the listener onResult is called. But if we don't respond, and there is no callback getting called. The onError callback used to call with SpeechRecognizer.ERROR_SPEECH_TIMEOUT

Is there anyone having this issue?

The same issue using the RecognizerIntent.ACTION_RECOGNIZE_SPEECH Intent . The onActivityResult is not called if no response . It use to timeout before and stopped working now.

This is how i'm starting the activity:

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL , RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE , this.getPackageName());
    startActivityForResult(intent , VOICE_REQUEST_CODE);

And the onActivityResult:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)  {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == VOICE_REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> stringArrayListExtra = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if(stringArrayListExtra != null && !stringArrayListExtra.isEmpty()) {
            voiceBuilder.append(stringArrayListExtra.toString());
            voiceBuilder.append("\n\n");
        }
    }
}

I've the sample project here https://github.com/libinbensin/GoogleVoiceTest-

来源:https://stackoverflow.com/questions/42919038/speechrecognizer-doesnt-timeout-when-silent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!