英文:
What is the use of get(0) in OnResult() method of SpeechRecognizer?
问题
我正在进行语音转文本识别的工作。在speechRecognizer
的OnResults()
方法中,代码片段中所指定的result.get(0)
的用途是什么?我发现它用于获取第一个结果,但这实际上是什么意思?
@Override
public void onResults(Bundle results) {
ArrayList<String> result = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
if(result != null){
edittext.setText(result.get(0));
}
}
英文:
I am working on speech to text recognition. In OnResults()
method of speechRecognizer, what is the use of result.get(0)
as specified in the below code snippet. I found out that it is used to get the first result but what does that actually mean?
@Override
public void onResults(Bundle results) {
ArrayList<String> result = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
if(result != null){
edittext.setText(result.get(0));
}
}
答案1
得分: 1
"ArrayList
您也可以查看结果,并根据您自己的启发式确定最有可能的候选者,但索引:0 是识别器认为最有可能的。
英文:
"ArrayList<String> from the Bundle [...] are the possible recognition results, where the first element is the most likely candidate." [https://developer.android.com/reference/android/speech/SpeechRecognizer#RESULTS_RECOGNITION]
You could also look at the results and determine by your own heuristic which is the most likely candidate, but index:0 is what the Recognizer deemed most likely.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论