Skip to content

Commit 021fb19

Browse files
authored
[Voice] Fix google and watson STT pcm format support (openhab#16464)
Signed-off-by: Miguel Álvarez <[email protected]>
1 parent a891956 commit 021fb19

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private void streamAudio(ClientStream<StreamingRecognizeRequest> clientStream, A
243243
// Gather stream info and send config
244244
AudioFormat streamFormat = audioStream.getFormat();
245245
RecognitionConfig.AudioEncoding streamEncoding;
246-
if (AudioFormat.WAV.isCompatible(streamFormat)) {
246+
if (AudioFormat.PCM_SIGNED.isCompatible(streamFormat) || AudioFormat.WAV.isCompatible(streamFormat)) {
247247
streamEncoding = RecognitionConfig.AudioEncoding.LINEAR16;
248248
} else {
249249
logger.debug("Unsupported format {}", streamFormat);

bundles/org.openhab.voice.watsonstt/src/main/java/org/openhab/voice/watsonstt/internal/WatsonSTTService.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ private String getModel(Locale locale) throws STTException {
208208
Long frequency = format.getFrequency();
209209
Integer bitDepth = format.getBitDepth();
210210
switch (container) {
211+
case AudioFormat.CONTAINER_NONE:
212+
if (AudioFormat.CODEC_MP3.equals(codec)) {
213+
return "audio/mp3";
214+
}
211215
case AudioFormat.CONTAINER_WAVE:
212216
if (AudioFormat.CODEC_PCM_SIGNED.equals(codec)) {
213217
if (bitDepth == null || bitDepth != 16) {
@@ -239,11 +243,6 @@ private String getModel(Locale locale) throws STTException {
239243
return "audio/ogg;codecs=opus";
240244
}
241245
break;
242-
case AudioFormat.CONTAINER_NONE:
243-
if (AudioFormat.CODEC_MP3.equals(codec)) {
244-
return "audio/mp3";
245-
}
246-
break;
247246
}
248247
return null;
249248
}

0 commit comments

Comments
 (0)