From 021fb19d317c80b6f9ab551a426b02054725ab9a Mon Sep 17 00:00:00 2001 From: GiviMAD Date: Mon, 26 Feb 2024 23:03:39 -0800 Subject: [PATCH] [Voice] Fix google and watson STT pcm format support (#16464) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Miguel Álvarez --- .../voice/googlestt/internal/GoogleSTTService.java | 2 +- .../voice/watsonstt/internal/WatsonSTTService.java | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java b/bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java index 0a7fef170c..a217c6a417 100644 --- a/bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java +++ b/bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java @@ -243,7 +243,7 @@ public class GoogleSTTService implements STTService { // Gather stream info and send config AudioFormat streamFormat = audioStream.getFormat(); RecognitionConfig.AudioEncoding streamEncoding; - if (AudioFormat.WAV.isCompatible(streamFormat)) { + if (AudioFormat.PCM_SIGNED.isCompatible(streamFormat) || AudioFormat.WAV.isCompatible(streamFormat)) { streamEncoding = RecognitionConfig.AudioEncoding.LINEAR16; } else { logger.debug("Unsupported format {}", streamFormat); diff --git a/bundles/org.openhab.voice.watsonstt/src/main/java/org/openhab/voice/watsonstt/internal/WatsonSTTService.java b/bundles/org.openhab.voice.watsonstt/src/main/java/org/openhab/voice/watsonstt/internal/WatsonSTTService.java index d5ea0029c8..70bff2a574 100644 --- a/bundles/org.openhab.voice.watsonstt/src/main/java/org/openhab/voice/watsonstt/internal/WatsonSTTService.java +++ b/bundles/org.openhab.voice.watsonstt/src/main/java/org/openhab/voice/watsonstt/internal/WatsonSTTService.java @@ -208,6 +208,10 @@ public class WatsonSTTService implements STTService { Long frequency = format.getFrequency(); Integer bitDepth = format.getBitDepth(); switch (container) { + case AudioFormat.CONTAINER_NONE: + if (AudioFormat.CODEC_MP3.equals(codec)) { + return "audio/mp3"; + } case AudioFormat.CONTAINER_WAVE: if (AudioFormat.CODEC_PCM_SIGNED.equals(codec)) { if (bitDepth == null || bitDepth != 16) { @@ -239,11 +243,6 @@ public class WatsonSTTService implements STTService { return "audio/ogg;codecs=opus"; } break; - case AudioFormat.CONTAINER_NONE: - if (AudioFormat.CODEC_MP3.equals(codec)) { - return "audio/mp3"; - } - break; } return null; } -- 2.47.3