I want pocketsphinx to listen for certain keywords and do respective actions instead of going to the menu like their demo app. I have three keywords
private static final String KEYPHRASE1 = "good morning";
private static final String KEYPHRASE2 = "good evening";
private static final String KEYPHRASE3 = "good night";
This is my onPartialResult()
@Override
public void onPartialResult(Hypothesis hypothesis) {
if (hypothesis == null)
return;
String text = hypothesis.getHypstr();
}
I want to call some methods directly when it recognizes the three keywords. I also don't know whether I need to use switchSearch()
and KWS_SEARCH
like in the demo app.
I am new to android and I searched days for the answer. Someone, please help. This speech recognition is necessary for my app.
You have asked two question so I will answer them both in points.
onPartialResult()
and onResult
. The former is used to get quick updates about the words being spoken while the latter is used to get the predictions after the recognizer has been stopped, i.e. after all the keywords have been spoken and the user has stopped the recognizer.onPartialResult()
or onResult()
. After that, notice that both methods perform some operations on the recognized text. onPartialResult()
calls switchSearch()
while onResult()
calls makeText()
. In your case too, you want to call some function when it recognizes your three keywords. Create a function in the same class and call it as you'd normally call the function anywhere else in your program!