java - Voice recognition/dictation for Android -
good day,
i in stages of building cooking/recipe app. main purpose of app able follow , traverse recipes using voice dictation. can point me in right direction on how implement these features?
thanks!
call system's built-in speech recognizer activity obtain speech input users. useful obtain input users , process it, such doing search or sending message.
in app, call startactivityforresult() using action_recognize_speech action. starts speech recognition activity, , can handle result in onactivityresult().
private static final int speech_request_code = 0; // create intent can start speech recognizer activity private void displayspeechrecognizer() { intent intent = new intent(recognizerintent.action_recognize_speech); intent.putextra(recognizerintent.extra_language_model, recognizerintent.language_model_free_form); // start activity, intent populated speech text startactivityforresult(intent, speech_request_code); } // callback invoked when speech recognizer returns. // process intent , extract speech text intent. @override protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == speech_request_code && resultcode == result_ok) { list<string> results = data.getstringarraylistextra( recognizerintent.extra_results); string spokentext = results.get(0); // spokentext } super.onactivityresult(requestcode, resultcode, data); }
Comments
Post a Comment