java - Speech recognition in Android -
I am working on speech recognition and some sample programs are required.
Can anyone guide me?
will show me which code you'll need I
edit You can also download an easy abstract class from you.
You will need this effect (parasitization as you see fit):
Get the public intro recognizer (string promptuuse, extracted maxResultsToReturn) {intent = new Intent (RecognizerIntent.ACTION_RECOGNIZE_SPEECH); Intent.putExtra (RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); Intent.putExtra (RecognizerIntent.EXTRA_MAX_RESULTS, maxResultsToReturn); Intent.putExtra (RecognizerIntent.EXTRA_PROMPT, promptToUse); Intent to return; }
Then you need to send your motivation like speech recognition activity,
collect public zodiac sign (string prompt) {intro detection = receive Do Recognizer (Quick); Try {StartActivityForResult (Identifier, Boligator.VOICE_RECOGNITION_REQUEST_CODE); } Catch (ACTIVITY FOOTDOWN APPLICATION ACT NOTOUND) {log. W (D.OoLG, "speech activity not found, is not doing it"); }}
Then you will need to handle the result of the speech on your activity:
Protected Zero on Activeivity Result (Int RequestCode, Inc as a result code, Intent data) {log d. ("Speech", "Get Speech Results" + resultcode + "Reiki:" + Requestcode); If (requestcode == Speaker VOICE_RECOGNITION_REQUEST_CODE) {if (resultCode == RESULT_OK) {ArrayList & lt; String & gt; Matches = Data .getStringArrayListExtra (RecognizerIntent.EXTRA_RESULTS); Log D. (D.O.L.G., "Matches:"); For (string match: matches) {log d. (D_LOG, match); }}}}
Comments
Post a Comment