I am using pocketsphinx to spot a keyword continuously in a service. The problem is, it takes up a huge amount of battery, making the app completely unusable for an average user.
Well, the original code is in B4A, but this is how it will look:
recognizer = defaultSetup()
.setAcousticModel(new File(assetsDir, "en-us-ptm"))
.setDictionary(new File(assetsDir, "cmudict-en-us.dict"))
.setRawLogDir(assetsDir).setKeywordThreshold(1e-20f)
.getRecognizer();
recognizer.addListener(this);
For the keyword:
// Create keyword-activation search.
recognizer.addKeyphraseSearch(KWS_SEARCH, "extreme");
I even excluded the following to decrease the CPU consumption. After all, my main goal is just to spot the keyword.
// Create grammar-based searches.
File menuGrammar = new File(assetsDir, "menu.gram");
recognizer.addGrammarSearch(MENU_SEARCH, menuGrammar);
// Next search for digits
File digitsGrammar = new File(assetsDir, "digits.gram");
recognizer.addGrammarSearch(DIGITS_SEARCH, digitsGrammar);
// Create language model search.
File languageModel = new File(assetsDir, "weather.dmp");
recognizer.addNgramSearch(FORECAST_SEARCH, languageModel);
Is there any other way in which service could possibly use less battery?