0

I'm trying to make an Android Wear project with Offline Voice Recognition. It works online, connected with the phone, but i want the Wear Device to be independent.

This is my code working for online recognition :

private static final int SPEECH_RECOGNIZER_REQUEST_CODE = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
    startSpeechRecognition();
}

private void startSpeechRecognition() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    startActivityForResult(intent, SPEECH_RECOGNIZER_REQUEST_CODE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SPEECH_RECOGNIZER_REQUEST_CODE) {      
        if (resultCode == RESULT_OK) {
            List<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            String recognizedText = results.get(0);
            Log.d("VOICE TEST : ", recognizedText);
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

Thanks a lot.

Da Guigz
  • 1
  • 1
  • I am pretty sure that Google's voice recognition software works only when you are online EDIT: looks like I was wrong, check this out: http://stackoverflow.com/questions/17616994/offline-speech-recognition-in-android-jellybean – RN_ Jul 03 '15 at 17:08
  • Not sure if this is still required but it looks like Google will be adding offline vocal recognition functionality in Android M / 6.0 / Marshmallow at least for phones. But a wear device may be able to tap into this capability. See Link http://developer.android.com/reference/android/speech/RecognizerIntent.html#EXTRA_PREFER_OFFLINE – Seb Andraos Sep 23 '15 at 10:01

1 Answers1

0

The Android Wear speech recognizer requires a connection to the phone and the internet to work. So what you are trying to achieve is not possible.

You can test this out yourself by disconnecting the phone from the wearable, and then trying to use any of the "Ok Google" commands. It does not work.

Wayne Piekarski
  • 3,203
  • 18
  • 19