Google Glass and Speech Recognizer time delay recognizing results

↘锁芯ラ 提交于 2019-12-13 18:31:55

问题


I am working on a Glass application that will perform "Next Card" and "Previous Card" via speech. The application works just fine, except the time from when the word is spoken to when the action is performed is just over 1 second. This is a long enough delay that it is noticeable. This does not respond as quickly as Google has it with "ok glass".

The most obvious change seems to be to implement: EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS and/or EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS and/or EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS

but this currently has no effect. It is also noted on Android's RecognizerIntent webpage for all 3 of these: "Note also that certain values may cause undesired or unexpected results - use judiciously! Additionally, depending on the recognizer implementation, these values may have no effect."

Here is the code as to how this is implemented in main:

        speechIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    speechIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getApplication().getPackageName());
    speechIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
    speechIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, Long.valueOf(100));
    speechIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, Long.valueOf(100));
    speechIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, Long.valueOf(100));

    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
    speechRecognizer.setRecognitionListener(this);

    if (SpeechRecognizer.isRecognitionAvailable(this)) {
        speechRecognizer.startListening(speechIntent);

        }

I have tried to replace Long.valueOf() with new Long() and also just 100 (I also tried the value of 500 if for some reason 100 is just to small). Eclipse's warning recommended using Long.valueOf().

The results are coming back on onPartialResults, this process works better then onResults since onResults waits for a pause. Because of testing the 3 extras above, I had the results coming back onResults, but there was no change.

Any ideas on what I am missing here? If you need to see more code, let me know. Thank you.


回答1:


For brief commands like this, you should use a contextual voice menu instead of the speech recognizer for better results.

You can see a list of currently approved commands here, but during development you can use whatever commands you want (by adding the development permission to your manifest).

Make sure to also submit any new voice commands that you might need if you would like to go through the review process and launch in the future.



来源:https://stackoverflow.com/questions/25981496/google-glass-and-speech-recognizer-time-delay-recognizing-results

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