Android Voice Listener

I would like to add a voice command listener in my application. The service must listen to a predefined keyword and, if a keyword is specified, it must call some method.

Voice command recognition (activation command) should work without sending requests to Google voice servers.

How can I do this on Android?

Thanks for posting useful resources.

+4
android voice-recognition google-voice
Jun 20 '14 at 7:16
source share
1 answer

You can use Pocketsphinx to complete this task. Check out the demo version of Pocketsphinx android , for example, how to efficiently use the keyword offline and respond to certain commands, for example, the keyword phrase "about a powerful computer." The code for this is simple:

you create a recognizer and just add a search for keywords:

recognizer = SpeechRecognizerSetup.defaultSetup() .setAcousticModel(new File(modelsDir, "hmm/en-us-semi")) .setDictionary(new File(modelsDir, "lm/cmu07a.dic")) .setKeywordThreshold(1e-40f) .getRecognizer(); recognizer.addListener(this); recognizer.addKeyphraseSearch("keywordSearch", "oh mighty computer"); recognizer.startListening("keywordSearch); 

and identify the listener:

 @Override public void onPartialResult(Hypothesis hypothesis) { if (hypothesis == null) return; String text = hypothesis.getHypstr(); if (text.equals(KEYPHRASE)) { // do something and restart listening recognizer.cancel(); doSomething(); recognizer.startListening("keywordSearch"); } } 

You can adjust the keyword threshold for the best match detection / false positive. For an ideal keyword for definition there should be at least 3 syllables, preferably 4 syllables.

+4
Jun 20 '14 at 7:55
source share



All Articles