Android的SpeechRecognizer"信心和QUOT;值混淆 [英] Android SpeechRecognizer "confidence" values are confusing

查看:200
本文介绍了Android的SpeechRecognizer"信心和QUOT;值混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过意向使用SpeechRecognizer:

I'm using the SpeechRecognizer via Intent:

Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

i.putExtra(RecognizerIntent.EXTRA_PROMPT,
        "straight talk please");

i.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, 
            "en-US";

startActivityForResult(i, 0);

和我得到的结果onActivityResults()是这样的:

And I get the results in onActivityResults() like this:

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

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

        // List with the results from the Voice Recognition API
        ArrayList<String> results = data
                .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

        // The confidence array
        float[] confidence = data.getFloatArrayExtra(
                RecognizerIntent.EXTRA_CONFIDENCE_SCORES);

        // The confidence results       
        for (int i = 0; i < confidence.length; i++) {
            Log.v("oAR", "confidence[" + i + "] = " + confidence[i]);
        }
    }

    super.onActivityResult(requestCode, resultCode, data);
}

但float数组始终返回0.0的结果,但像他这样的第一个元素:

But the float array always returns 0.0 as result, but the first element like this:

confidence[0] = any value between 0 and 1
confidence[1] = 0.0
confidence[2] = 0.0
and so on

我希望每个结果的值介于0和1之间的置信度值,否则似乎pretty的没用,因为结果具有最高的信心将是默认的第一个元素,而无需使用 EXTRA_CONFIDENCE_SCORES 。有我丢失的东西?

I would expect that every result has a confidence value between 0 and 1. Otherwise it seems pretty useless, because the result with the highest confidence will be the first element by default, without using the EXTRA_CONFIDENCE_SCORES. Is there something I'm missing?

此外, RecognizerIntent.EXTRA_CONFIDENCE_SCORES 应该在 API等级14 ++ 使用。但它并不重要其上高于8 API第I使用它的结果保持不变。是文档过时在这一点?

Furthermore the RecognizerIntent.EXTRA_CONFIDENCE_SCORES is supposed to be used in API Level 14++. But it doesn't matter on which API above 8 I use it the result stays the same. Are the docs out of date in that point?

推荐答案

我没有言语重组工作。但尽管如此,因为你说你越来越float数组值为0.0,这意味着 int数组为null 。你可以请检查浮子[]是返回null否则后果不堪设想。

I haven't work with speech reorganization. But still, as you said you are getting float array value as 0.0, this implies float array is null . can you please check is the float[] is returning null or else.

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

float[] confidence = data.getFloatArrayExtra(
            RecognizerIntent.EXTRA_CONFIDENCE_SCORES);
if (confidence == null)
{
 for (int i = 0; i < results.size(); i++)
  {
   Log.d(TAG, i + ": " + results.get(i));
  }
}
else
{
   for (int i = 0; i < results.size(); i++)

   {
     Log.d(TAG, i + ": " + heard.get(i) + " confidence : "  + confidence[i]);
  }
}

您可以请检查这本书的专业的Andr​​oid传感器编程格雷格Milette,亚当斯特劳德的这一定会帮助你的。你会得到页<一个就一些细节问题href="http://books.google.co.in/books?id=yi-WNEGcO0EC&printsec=frontcover#v=onepage&q=float%5B%5D%20scores%20=%20data.%20getFloatArrayExtra%20%28RecognizerIntent.EXTRA_CONFIDENCE_SCORES%29;&f=false"相对=nofollow> 394 这本书。

Can you please check the book Professional Android Sensor Programming  By Greg Milette, Adam Stroud this will surely help you. You will get some details on page 394 on this book.

这篇关于Android的SpeechRecognizer&QUOT;信心和QUOT;值混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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