diff --git a/bundles/org.openhab.voice.rustpotterks/src/main/java/org/openhab/voice/rustpotterks/internal/RustpotterKSService.java b/bundles/org.openhab.voice.rustpotterks/src/main/java/org/openhab/voice/rustpotterks/internal/RustpotterKSService.java index c31982e50..e6f4f8ada 100644 --- a/bundles/org.openhab.voice.rustpotterks/src/main/java/org/openhab/voice/rustpotterks/internal/RustpotterKSService.java +++ b/bundles/org.openhab.voice.rustpotterks/src/main/java/org/openhab/voice/rustpotterks/internal/RustpotterKSService.java @@ -191,12 +191,11 @@ public class RustpotterKSService implements KSService { while (!aborted.get()) { try { numBytesRead = audioStream.read(audioBuffer, bufferSize - remaining, remaining); - if (aborted.get()) { + if (aborted.get() || numBytesRead == -1) { break; } if (numBytesRead != remaining) { remaining = remaining - numBytesRead; - Thread.sleep(100); continue; } remaining = bufferSize; @@ -217,7 +216,7 @@ public class RustpotterKSService implements KSService { detection.delete(); ksListener.ksEventReceived(new KSpottedEvent()); } - } catch (IOException | InterruptedException e) { + } catch (IOException e) { String errorMessage = e.getMessage(); ksListener.ksEventReceived(new KSErrorEvent(errorMessage != null ? errorMessage : "Unexpected error")); }