在SpeechRecognizer的OnResult()方法中,get(0)的用途是什么?

huangapple go评论117阅读模式
英文:

What is the use of get(0) in OnResult() method of SpeechRecognizer?

问题

我正在进行语音转文本识别的工作。在speechRecognizerOnResults()方法中,代码片段中所指定的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&lt;String&gt; result = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if(result != null){
        edittext.setText(result.get(0));
    }
}

答案1

得分: 1

"ArrayList 来自 Bundle [...] 是可能的识别结果,其中第一个元素是最有可能的候选者。" [https://developer.android.com/reference/android/speech/SpeechRecognizer#RESULTS_RECOGNITION]

您也可以查看结果,并根据您自己的启发式确定最有可能的候选者,但索引: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.

huangapple
  • 本文由 发表于 2020年5月29日 15:12:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/62080561.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定