SpeechRecognizer在静默时不会超时

时间:2017-03-21 05:27:17

标签: android android-speech-api

随着最近的Google App更新(6.14.20.21.arm),谷歌语音识别器停止工作。如果您在识别器启动后的几秒钟内响应,则会调用侦听器onResult。但是如果我们没有回应,并且没有回叫。 onError回调过去曾使用SpeechRecognizer.ERROR_SPEECH_TIMEOUT

进行调用

有人有这个问题吗?

使用RecognizerIntent.ACTION_RECOGNIZE_SPEECH意图的同一问题。如果没有响应,则不会调用onActivityResult。它用于在之前超时并且现在停止工作。

这就是我开始活动的方式:

    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);

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");
        }
    }
}

我在这里的示例项目https://github.com/libinbensin/GoogleVoiceTest-

0 个答案:

没有答案