[Voice] Fix google and watson STT pcm format support (#16464)

Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
This commit is contained in:
GiviMAD 2024-02-26 23:03:39 -08:00 committed by GitHub
parent a891956683
commit 021fb19d31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View 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);

View 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;
}