use of org.eclipse.smarthome.core.voice.SpeechRecognitionEvent in project smarthome by eclipse.
the class DialogProcessor method sttEventReceived.
@Override
public synchronized void sttEventReceived(STTEvent sttEvent) {
if (sttEvent instanceof SpeechRecognitionEvent) {
if (false == this.isSTTServerAborting) {
this.sttServiceHandle.abort();
this.isSTTServerAborting = true;
SpeechRecognitionEvent sre = (SpeechRecognitionEvent) sttEvent;
String question = sre.getTranscript();
try {
toggleProcessing(false);
String answer = hli.interpret(this.locale, question);
if (answer != null) {
say(answer);
}
} catch (InterpretationException e) {
say(e.getMessage());
}
}
} else if (sttEvent instanceof RecognitionStopEvent) {
toggleProcessing(false);
} else if (sttEvent instanceof SpeechRecognitionErrorEvent) {
if (false == this.isSTTServerAborting) {
this.sttServiceHandle.abort();
this.isSTTServerAborting = true;
toggleProcessing(false);
SpeechRecognitionErrorEvent sre = (SpeechRecognitionErrorEvent) sttEvent;
say("Encountered error: " + sre.getMessage());
}
}
}
Aggregations