0

So I need to grab single characters from the user in google glass. This is for entering passwords, captchas, spelling user names, etc. I've tried using the sample code:

private static final int SPEECH_REQUEST = 0;

private void displaySpeechRecognizer() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    startActivityForResult(intent, SPEECH_REQUEST);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SPEECH_REQUEST && resultCode == RESULT_OK) {
        List<String> results = data.getStringArrayListExtra(
            RecognizerIntent.EXTRA_RESULTS);
        String spokenText = results.get(0);
        // Do something with spokenText.
    }
    super.onActivityResult(requestCode, resultCode, data);
}

But it seems to try and always interpret what I'm saying as words. It works okay for numbers, but when trying to spell characters like a password, I get random results.

johnarleyburns
  • 1,532
  • 12
  • 13
  • Uhm. I don't know whether it's a good idea to let the user spell the password aloud. Usually a password isn't displayed on the screen since other people may read it... spelling it aloud is even worse. – Bakuriu Jan 29 '14 at 09:57
  • Captcha spellings are my first problem, which don't have security issues. Aloud for passwords only needs to be secure if people are listening, like in a common area, it's true that some gesture-based or head-tracking mechanism would be better like the android lock screen pattern. Captchas are the main problem right now, but also maybe I want to spell a URL to visit. – johnarleyburns Jan 29 '14 at 17:13
  • You could go old school and use a phonetic alphabet http://en.wikipedia.org/wiki/NATO_phonetic_alphabet. – Jay Carlton Jan 30 '14 at 17:23

1 Answers1

0

You could try using this method and passing in an array of letters, you can also run this within an activity so you could keep on the same page, just adding each letter to a view as it is heard and carry on listening until you it hears 'finish' or something similar.

Community
  • 1
  • 1
Ben
  • 1,767
  • 16
  • 32