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.