gpt4 book ai didi

android - 从语音识别器中获取类似于 Google Now 返回结果的短语

转载 作者:行者123 更新时间:2023-11-29 01:31:21 25 4
gpt4 key购买 nike

我目前正在构建我的应用程序的一项功能,允许用户说出一个短语,然后将其与另一个用户说出的短语进行比较,以确定它们是否相等。我正在从语音识别器 Intent 中返回结果,如下所示。

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {

ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

当我通过说“测试 123”来尝试时,我得到了一个填充有“测试 123,测试一二三,Piscon 123”的数组

有没有办法只从结果中提取最准确的短语,例如“Testing 123”?当我使用 Google Now 进行搜索时,只会返回我所说内容的最准确表示,所以我想知道是否可以实现此功能。

我尝试了“你能跳多高”并得到了这个结果。有没有办法确定下一个句子的开始,以便我可以提取最积极的结果?

enter image description here

最佳答案

如果您想获得最准确的分数,您还需要获取 EXTRA_CONFIDENCE_SCORES。您需要找到最高置信度分数和相应的字符串值。来自 documentation

public static final String EXTRA_RESULTS

Added in API level 3An ArrayList of the recognition results when performing ACTION_RECOGNIZE_SPEECH. Generally this list should be ordered in descending order of speech recognizer confidence. (See EXTRA_CONFIDENCE_SCORES). Returned in the results; not to be specified in the recognition request. Only present when RESULT_OK is returned in an activity result. In a PendingIntent, the lack of this extra indicates failure.

和置信度分数:

public static final String EXTRA_CONFIDENCE_SCORES

Added in API level 14A float array of confidence scores of the recognition results when performing ACTION_RECOGNIZE_SPEECH. The array should be the same size as the ArrayList returned in EXTRA_RESULTS, and should contain values ranging from 0.0 to 1.0, or -1 to represent an unavailable confidence score.

Confidence values close to 1.0 indicate high confidence (the speech recognizer is confident that the recognition result is correct), while values close to 0.0 indicate low confidence.

Returned in the results; not to be specified in the recognition request. This extra is optional and might not be provided. Only present when RESULT_OK is returned in an activity result.

关于android - 从语音识别器中获取类似于 Google Now 返回结果的短语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31057510/

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