【发布时间】:2015-02-20 15:42:35
【问题描述】:
我正在尝试离线使用Android的语音识别API,就像这个问题Android Offline Speech Recognition shows only one result?一样。在线时我也得到五个结果,离线时只有一个结果,并且希望在任何一种情况下都得到五个(ish)结果。这仅仅是 Android 内置语音识别引擎的限制,还是有一些隐藏设置可以更改以强制产生多个结果?
这是我的 Intent 设置:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); //< have tried both FREE_FORM and WEB_SEARCH
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getPackageName());
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
mRecognizer.startListening(intent);
还有我的 onResults():
@Override
public void onResults(Bundle results) {
// data.size() is 1, if running offline and generally 5, if online
ArrayList<String> data = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
//...
}
我运行的是 Android 4.4.2。
【问题讨论】:
-
为什么你问的问题和已经存在的完全一样?
-
因为那个问题没有答案。
-
你可以对原来的问题投赞成票
-
我没有投票的声誉,所以我问了同样的问题。另一个问题是一年前问的,它甚至没有任何cmets。
-
我还没有找到任何证据表明这种行为不仅仅是 Android 语音识别 API 的限制。我将识别引擎切换到 CMU Sphinx (cmusphinx.sourceforge.net)。它使用起来并不简单,但也不算太糟糕。 CMU Sphinx 是非常可配置的,经过一点声学模型调整后,我使用 CMU Sphinx 的简单命令和控制应用程序最终能够获得比使用 Android API 更好的识别结果。
标签: android speech-recognition