SpeechRecognizer工作了很长时间,突然它无法正常工作现在没有检测到任何东西..示例代码是这样的。当它在线时它工作正常但不能脱机,我在任何地方都遗漏了什么吗?
SpeechRecognizer speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
i.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
speechRecognizer.setRecognitionListener(new RecognitionListener() {
@Override
public void onReadyForSpeech(Bundle params) {
}
@Override
public void onBeginningOfSpeech() {
}
@Override
public void onRmsChanged(float rmsdB) {
}
@Override
public void onBufferReceived(byte[] buffer) {
}
@Override
public void onEndOfSpeech() {
//speechRecognizer.stopListening();
}
@Override
public void onError(int error) {
}
@Override
public void onResults(Bundle results) {
List<String> data = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
String full = data.get(0);
System.out.println(full);
}
@Override
public void onPartialResults(Bundle partialResults) {
}
@Override
public void onEvent(int eventType, Bundle params) {
}
});
speechRecognizer.startListening(i);`