我想在服务中使用 pocketsphinx 连续收听“hello”这个词
我得到了错误。这里是完整的堆栈跟踪 https://gist.github.com/anonymous/d68e9ac7e5d98315a5a4。这是其中的一小部分。
Unable to create service curlybrace.ruchir.myApp.MyService: java.lang.RuntimeException: new_Decoder returned -1
其原因是这样的:
setupRecognizer(assetDir); //SETUP
和这个:
.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();
}
这是我的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
}
这是实现的方法之一:
@Override
public void onPartialResult(Hypothesis hypothesis) {
String text = hypothesis.getHypstr();
if (text.equals("Hello")) {
// do something
Log.v(TAG, "SPEECH RECOGNIZED HELLO!");
}
}
如果有任何反馈,我将不胜感激。正面的、负面的,甚至是评论。经过两天的尝试,此时我绝望了!