How to connect SpeechRecognizer to RecognizerIntent with Extras

為{幸葍}努か 提交于 2019-12-22 10:45:05

问题


I am trying to wrap my mind around the SpeechRecognizer. I have a SpeechRecognizer with my own Recognition Listener:

rec = SpeechRecognizer.createSpeechRecognizer(this);
    rec.setRecognitionListener(new RecognitionListener() {
        //Lots of overrides that work perfectly fine
    });

Wich works fine when I launch it by using rec.startListening(intent); But my intent happens to have some Extras:

        intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
    intent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, true);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "de-DE");
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);

    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

All of those, the Recognizer rec totally ignores when launching with rec.startListening(intent);

On the other hand, when I use startActivityForResult(intent, 1000, intent.getExtras()); to start the recognition, the Code from the RecognitionLister is totally ignored.

How do I start the recognition with my own RecognitionListener AND the intent-extras?

Layna

=============

PS: I have by now realised that startActivityForResult has absolutely no reason to use the code for the ReconitionListener.... but I am still confused why startListening should ignore extras.

来源:https://stackoverflow.com/questions/16278048/how-to-connect-speechrecognizer-to-recognizerintent-with-extras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!