我想在服务中不断地使用pocketsphinx来听取hello这个词
我收到了错误.这是full stack trace.这是它的一小部分.
Unable to create service curlybrace.ruchir.myApp.MyService: java.lang.RuntimeException: new_Decoder returned -1
这是由于:
setupRecognizer(assetDir); //SETUP
和这个:
.getRecognizer();
在我的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();
}
这是我的setupRecognizer方法:
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
}
这是实现的方法之一:
@Override
public void onPartialResult(Hypothesis hypothesis) {
String text = hypothesis.getHypstr();
if (text.equals("Hello")) {
// do something
Log.v(TAG, "SPEECH RECOGNIZED HELLO!");
}
}
我将不胜感激任何反馈.积极的,消极的,甚至是评论.在这一点上,经过2天的努力,我绝望了!