i got a problem with PocketSphinx, whenever i execute that Code, the app automatically shuts down. As i already try to figure out why it doesnt work for hours , maybe someone can help me? :) so far the code looks like this,
Main:
public class MainActivity extends Activity implements RecognitionListener {
public SpeechRecognizer recognizer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try
{
Assets assets = new Assets(MainActivity.this);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
}
catch (IOException e)
{
}
}
setupRecognizer:
private void setupRecognizer(File assetsDir)
{
try {
recognizer = defaultSetup()
.setAcousticModel(new File(assetsDir, "en-us-ptm"))
.setDictionary(new File(assetsDir, "cmudict-en-us.dict"))
.setRawLogDir(assetsDir).setKeywordThreshold(1e-20f)
.setBoolean("-allphone_ci", true)
.getRecognizer();
recognizer.addListener(this);
recognizer.addKeyphraseSearch("keywordsearch", "oh mighty Computer");
recognizer.startListening("keywordsearch");
} catch (IOException e) {
}
onPartialResult:
public void onPartialResult(Hypothesis hyp) {
if (hyp == null) {
}
TextView t = (TextView) findViewById(R.id.textviewcontrol);
t.setText("found");
recognizer.cancel();
}
maybe it helps: so far the app starts (=>does nothing but showing a textview) when i comment those lines out:
recognizer.addKeyphraseSearch("keywordsearch", "oh mighty Computer");
recognizer.startListening("keywordsearch");
when i only comment one of them out, it doesnt work.
so probably there is the mistake? I tried to import everything like in the tutorialcode for android, but i could also made a mistake there too.
thank you,
Jannis