1

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.

JenM
  • 11
  • 3

1 Answers1

0

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.

Tony Allevato
  • 6,429
  • 1
  • 29
  • 34
  • I am implementing a contextual voice menu at the introduction of the application, it is suitable there since there is a menu of options as to where the user can go within the application. Once the user is in a section, it works much more efficiently to only say "next" or "back" instead of having to say "ok glass" first, since user will be going through multiple cards. When you say to use the contextual voice menu "for better results" does it only have to do with the response time? Other aspects, other than the battery understandably, seem to work very well. Thanks for the quick response. – JenM Sep 22 '14 at 23:47