Continuous Speech Recognition Android
I am looking at doing speech recognition in android. The program needs to have continuous speech recognition. The library only needs to be about 10 words. I have considered using Googles api, but I don't think it will work. (I cannot have anything covering the screen). I have been looking into other ways but nothing seems like it will work. Is it possible to use java's speech recognition library, or is there any other way of going about this?
In summary
1. Need continuous speech input
2. 10 words at max
3. can train if necessary
4. overview of program - display screen, wait for voice input or touch input, update screen repeat
5. cannot cover what is being displayed on the screen
Any help would be appreciated.
Thanks in advance
Solution 1:
I think you would have to capture audio directly from the phone's microphone and stream it to your own recognition service. The Google recognition APIs are built as an Intent that launches their own Recognition dialog and gives you back results. If you want continuous recognition without a UI, you'll have to build that functionality yourself.
Solution 2:
CMUSphinx has recently implemented continuous listening on Android platform. You can find the demo on the wiki page
You can configure one or multiple keywords to listen to, the default keyword is "oh mighty computer". You also can configure the detection threshold. Currently supported languages are US English and few others (French, Spanish, Russian, etc). You can train your own model for your language.
Listening is simple, you create a recognizer and just add keyword spotting search:
recognizer = defaultSetup()
.setAcousticModel(new File(modelsDir, "hmm/en-us-semi"))
.setDictionary(new File(modelsDir, "lm/cmu07a.dic"))
.setKeywordThreshold(1e-5f)
.getRecognizer();
recognizer.addListener(this);
recognizer.addKeywordSearch(KWS_SEARCH_NAME, KEYPHRASE);
switchSearch(KWS_SEARCH_NAME);
and define a listener:
@Override
public void onPartialResult(Hypothesis hypothesis) {
String text = hypothesis.getHypstr();
if (text.equals(KEYPHRASE))
// do something
}
Instead of single key phrase you can specify a commands file path on a filesystem:
recognizer.addKeywordSearch(KWS_SEARCH, new File(assetsDir,
"commands.lst").toString());
Which commands file commands.lst
containing commands one per line:
oh might computer
ok google
hello dude
To put this file on filesystem you can put it in assets and run syncAssets on application start.
Solution 3:
Here is another way (if you are planning to use Phonegap/Cordova).
https://stackoverflow.com/a/39695412/3603128
1) It listens continuously.
2) Does not display (occupy) on screen.
Solution 4:
Use CMUSphinx library:
- It will work in offline mode
- You can name it up
- It will start listens when you call his name