I want to listen for the word hello using pocketsphinx in a service continuously
I get the error. Here is the full stack trace. Here is a small portion of it.
Unable to create service curlybrace.ruchir.myApp.MyService: java.lang.RuntimeException: new_Decoder returned -1
It is caused by this:
setupRecognizer(assetDir); //SETUP
and this:
.getRecognizer();
In my onCreate
:
Log.v(TAG, "Voice recognition activated!");
//Register voice recog listener :)
Assets assets = null;
try {
assets = new Assets(MyService.this);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir); //SETUP
Log.v(TAG, "Set up listener");
} catch (IOException e) {
e.printStackTrace();
}
Here is my setupRecognizer
method:
private void setupRecognizer(File assetDir) throws IOException {
recognizer = defaultSetup()
.setAcousticModel(new File(assetDir, "hmm/en-us-semi"))
.setDictionary(new File(assetDir, "lm/cmu07a.dic"))
.setKeywordThreshold(1e-5f)
.getRecognizer();
recognizer.addListener(this);
// recognizer.addKeywordSearch("Hello", assetDir); //I don't know what this does...
recognizer.startListening("Hello"); //Start listeneing
}
Here is one of the implemented methods:
@Override
public void onPartialResult(Hypothesis hypothesis) {
String text = hypothesis.getHypstr();
if (text.equals("Hello")) {
// do something
Log.v(TAG, "SPEECH RECOGNIZED HELLO!");
}
}
I would appreciate any feedback. Positive, negative, even a comment. At this point I am desperate, after trying for 2 days!
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
– Guenonservice can't start
, shouldn't I have gotten asecurity exception
? – Guenon