0

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?

Praharsh Bhatt
  • 556
  • 5
  • 24
  • I don't think that continuously listening for a keyword can be battery friendly in any way. Or is it only when your app is open? Devices like Alexa probably have a hardware component that handles this, and let the device sleep with almost no battery usage. – Peterdk Jun 03 '17 at 21:14
  • Hi, @Peterdk I have given an option to start listening only when the screen is on (It listens to the hotword even if the app is closed, from a service). That relatively saves more battery. Well, Google's VR is active, listening for commands every time. it does not use battery and resources as much as pocketphinx does.. – Praharsh Bhatt Jun 04 '17 at 05:41
  • I assume that the code to only listen to the keyword for Google is highly optimized. Using a generic library probably uses much more processing time. – Peterdk Jun 04 '17 at 21:17

1 Answers1

0

Since you are using microphone, changes in your program code won't dramatically solve battery draining issue. You can figure out a way to stop using microphone for recognition in certain times when not necessary.

SafalFrom2050
  • 687
  • 6
  • 12
  • Hi. Well, that helps. I have already added an option in my app for running pocketsphinx only when the screen is on. Still, it takes up too much resources and battery. Google's hotword recognition service is active almost all the time, and it does not affect battery in any ways! – Praharsh Bhatt Jun 04 '17 at 05:48