gpt4 book ai didi

android - SpeechRecognizer 突然无法离线工作

转载 作者:行者123 更新时间:2023-12-05 00:22:03 26 4
gpt4 key购买 nike

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

最佳答案

默认情况下,语音识别仅在线工作。识别过程需要大量的内存分配,如果你想要一个离线引擎,你应该避免使用默认的Android识别服务。

看看这个post .

关于android - SpeechRecognizer 突然无法离线工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30200013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com