SpeechRecognizer错误4 ERROR_SERVER-服务器发送错误状态

时间:2019-01-20 07:28:46

标签: android speech-recognition speech-to-text google-speech-api android-speech-api

Google是什么意思-“服务器错误”?这不是特别有用的错误。有人见过这个错误吗?

我在这里发布代码。该代码通常可以正常工作,并且发生这种情况的设备很少,所以我想这更多与设备的配置有关。

        intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,lang);
        intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS,interimResults);
        intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 20000);
        intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 20000);
        intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 10000);
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            intent.putExtra("android.speech.extra.PREFER_OFFLINE", true);
        }
        intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,maxResults);

        Handler loopHandler = new Handler(Looper.getMainLooper());
        loopHandler.post(new Runnable() {

            @Override
            public void run() {
                recognizer.startListening(intent);
            }

        });

0 个答案:

没有答案