]> git.basschouten.com Git - openhab-addons.git/commitdiff
[Voice] Fix google and watson STT pcm format support (#16464)
authorGiviMAD <GiviMAD@users.noreply.github.com>
Tue, 27 Feb 2024 07:03:39 +0000 (23:03 -0800)
committerGitHub <noreply@github.com>
Tue, 27 Feb 2024 07:03:39 +0000 (08:03 +0100)
Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java
bundles/org.openhab.voice.watsonstt/src/main/java/org/openhab/voice/watsonstt/internal/WatsonSTTService.java

index 0a7fef170cf7dcd44aa5057dfa10888c0375cced..a217c6a4170683e32a5804fbdb15d39db13e9b7e 100644 (file)
@@ -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);
index d5ea0029c8d515295806214c3ac54c802f79d19e..70bff2a574206469e82e154978757aaedcb1ebd8 100644 (file)
@@ -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;
     }