I have been creating an Android app which works fine when it is listening to one KeyPhrase with following config:
private static final String KWS_SEARCH = "wakeup";
private static final String KEYPHRASE = "oh mighty computer";
recognizer = SpeechRecognizerSetup.defaultSetup()
.setAcousticModel(new File(modelsDir, "hmm/en-us-semi"))
.setDictionary(new File(modelsDir, "dict/cmu07a.dic"))
.setKeywordThreshold(1e-20f)
.getRecognizer();
recognizer.addListener(this);
recognizer.addKeyphraseSearch(KWS_SEARCH, KEYPHRASE);
How can I add a second keyphrase which is recognized too? I tried the following:
private static final String KWS_SEARCH2 = "up";
private static final String KEYPHRASE2 = "hello my name is";
recognizer.addKeyphraseSearch(KWS_SEARCH2, KEYPHRASE2);
@Override
public void onPartialResult(Hypothesis hypothesis) {
if (hypothesis == null)
return;
String text = hypothesis.getHypstr();
if (text.equals(KWS_SEARCH))
restartRecognizer(KWS_SEARCH);
else if (text.equals(KWS_SEARCH2))
restartRecognizer(KWS_SEARCH2);
}
Thank you for help!