mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[Voice] Fix google and watson STT pcm format support (#16464)
Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
d4cdd56097
commit
cb8b3fb125
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user