语音识别获得低于14 API信心 [英] Speech Recognizer get confidence below API 14

查看:304
本文介绍了语音识别获得低于14 API信心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是与SpeechRecognizer 14 minSDK并添加一个过滤器,以获得最准确的结果。这code我在的onActivityResult()我的活动。

I'm using the SpeechRecognizer with minSDK 14 and added a filter to get the most accurate result. This code I have in onActivityResult() of my Activity.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == VOICE_RECOGNITION && resultCode == RESULT_OK) {

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

        // this is only available in API 14
        String confidenceExtra = RecognizerIntent.EXTRA_CONFIDENCE_SCORES; 
        float[] confidence = data.getFloatArrayExtra(confidenceExtra);

        // My filtering...
    }
}

由于过滤是基于每个结果的信心,我需要这个常量 RecognizerIntent.EXTRA_CONFIDENCE_SCORES 来能够请求的信心。但可悲的是,这只是在API 14 ++和AFAIK的语音识别提供未在支持包可用。

Because the filtering is based on the confidence of every result I need this constant RecognizerIntent.EXTRA_CONFIDENCE_SCORES to be able to request the confidence. But sadly this is only available in API 14++ and AFAIK the SpeechRecognition is not available in the Support Package.

有没有一种方式来获得更低的API级别的结果有信心吗?还是有一个变通的基础上其它值做一些过滤?

Is there a way to get the confidence for the results in lower API Levels? Or is there a work around to do some filtering based on other values?

推荐答案

与大多数Android的语音识别API的,这种额外的是可选的,可能不提供。 (引自规范)。

As with most of the Android speech recognition API, "This extra is optional and might not be provided." (quote from the spec).

我认为这是检查此float数组,即使在较低API级别是一个好主意(只是反向移植的 EXTRA_CONFIDENCE_SCORES 不变)。如果与该额外的浮动数组不是present然后就回落到假设 EXTRA_RESULTS 是由信心排序(API文档建议)。

I think it's a good idea to check for this float array even on lower API levels (just backport the EXTRA_CONFIDENCE_SCORES constant). If the float array corresponding to this extra is not present then just fall back to assuming that EXTRA_RESULTS is ordered by confidence (as the API documentation suggests).

这篇关于语音识别获得低于14 API信心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆