谷歌是什么意思 - “服务器错误”?这不是一个特别有用的错误。有没有人见过这个错误?
我在这里发布代码。代码通常可以正常工作,而且只有很少的设备会发生这种情况,所以我想这更多地与设备的配置有关。
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);
}
});