From: GiviMAD Date: Tue, 27 Feb 2024 07:03:39 +0000 (-0800) Subject: [Voice] Fix google and watson STT pcm format support (#16464) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=021fb19d317c80b6f9ab551a426b02054725ab9a;p=openhab-addons.git [Voice] Fix google and watson STT pcm format support (#16464) Signed-off-by: Miguel Álvarez --- 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; }