From b698fc538285d106865275089aa4e71fe2d9b841 Mon Sep 17 00:00:00 2001 From: amitkumarshukla Date: Thu, 29 Apr 2021 12:04:41 -0700 Subject: [PATCH] Adding any codec support for Go language speech sdk (#32) * adding any codec support for Go language speech sdk * some formating Co-authored-by: amishu --- audio/audio_stream_container_format.go | 3 +++ samples/recognizer/from_file.go | 14 ++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/audio/audio_stream_container_format.go b/audio/audio_stream_container_format.go index 1760e77..ff6bbc2 100644 --- a/audio/audio_stream_container_format.go +++ b/audio/audio_stream_container_format.go @@ -27,4 +27,7 @@ const ( // AMRWB Stream ContainerFormat definition for AMRWB. Currently not supported. AMRWB AudioStreamContainerFormat = 0x107 + + // ANY Stream ContainerFormat definition when the actual stream format is not known. + ANY AudioStreamContainerFormat = 0x108 ) diff --git a/samples/recognizer/from_file.go b/samples/recognizer/from_file.go index bd219df..cf25d3d 100644 --- a/samples/recognizer/from_file.go +++ b/samples/recognizer/from_file.go @@ -60,18 +60,16 @@ func RecognizeOnceFromCompressedFile(subscription string, region string, file st var containerFormat audio.AudioStreamContainerFormat if strings.Contains(file, ".mulaw") { containerFormat = audio.MULAW - } - if strings.Contains(file, ".alaw") { + } else if strings.Contains(file, ".alaw") { containerFormat = audio.ALAW - } - if strings.Contains(file, ".mp3") { + } else if strings.Contains(file, ".mp3") { containerFormat = audio.MP3 - } - if strings.Contains(file, ".flac") { + } else if strings.Contains(file, ".flac") { containerFormat = audio.FLAC - } - if strings.Contains(file, ".opus") { + } else if strings.Contains(file, ".opus") { containerFormat = audio.OGGOPUS + } else { + containerFormat = audio.ANY } format, err := audio.GetCompressedFormat(containerFormat) if err != nil {