From 0e0adcbb8f566b5559a03a9b2aa954b7b7a98f08 Mon Sep 17 00:00:00 2001 From: GiviMAD Date: Sat, 19 Feb 2022 14:01:41 +0100 Subject: [PATCH] [DialogProcessor] update say method nullability (#2780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miguel Álvarez Díez --- .../openhab/core/voice/internal/DialogProcessor.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/DialogProcessor.java b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/DialogProcessor.java index 8397a8d770..9870634ab6 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/DialogProcessor.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/DialogProcessor.java @@ -249,10 +249,7 @@ public class DialogProcessor implements KSListener, STTListener { String question = sre.getTranscript(); try { toggleProcessing(false); - String answer = hli.interpret(locale, question); - if (answer != null) { - say(answer); - } + say(hli.interpret(locale, question)); } catch (InterpretationException e) { String msg = e.getMessage(); if (msg != null) { @@ -280,7 +277,11 @@ public class DialogProcessor implements KSListener, STTListener { * * @param text The text to say */ - protected void say(String text) { + protected void say(@Nullable String text) { + if (text == null || text.isEmpty()) { + logger.debug("Empty value, nothing to say"); + return; + } try { Voice voice = null; for (Voice currentVoice : tts.getAvailableVoices()) {