Android SpeechRecognizer “confidence” values are confusing

后端 未结 3 697
灰色年华
灰色年华 2020-12-31 02:57

I\'m using the SpeechRecognizer via Intent:

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


        
3条回答
  •  情深已故
    2020-12-31 03:31

    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 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]);
      }
    }
    

    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.

提交回复
热议问题