Partial results using speech recognition

天大地大妈咪最大 提交于 2019-12-04 15:29:01

I suggest not relying on PARTIAL_RESULTS because the Google documentation says this: The server may ignore a request for partial results in some or all cases.

In my experience, Google almost always ignores requests for partial results.

However, I don't believe that setting EXTRA_PARTIAL_RESULTS should stop normal EXTRA_RESULTS from being returned. It should just have no effect. I have tested this in my code and adding EXTRA_PARTIAL_RESULTS doesn't change the output.

Also, unless you are using SpeechRecognizer, Android won't send you those error codes.

To see that EXTRA_PARTIAL_RESULTS does not interfere with the results. Get the code from here then add the extra within this method:

private void sendRecognizeIntent()
{
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say the magic word");
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 100);
    startActivityForResult(intent, SPEECH_REQUEST_CODE);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!