From cd223dfe54fa6bfc5775738b63e98d9701802e5f Mon Sep 17 00:00:00 2001 From: Sandra Rodgers Date: Wed, 19 Jul 2023 13:57:54 -0500 Subject: [PATCH 1/3] adds warning object --- SampleApp/Program.cs | 26 ++++++++------------------ SampleApp/SampleApp.csproj | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/SampleApp/Program.cs b/SampleApp/Program.cs index c1fc7a38..736b2ae8 100644 --- a/SampleApp/Program.cs +++ b/SampleApp/Program.cs @@ -5,30 +5,20 @@ namespace SampleApp { class Program { - const string API_KEY = "YOUR_DEEPGRAM_API_KEY"; + const string API_KEY = "24c13ac94b54bd2345dc5d5a93488de63d7d6531"; static async Task Main(string[] args) - { - var credentials = new Credentials(API_KEY); - DeepgramClient deepgram = new DeepgramClient(credentials); - - // UNCOMMENT IF USING LOCAL FILE: - // using (FileStream fs = File.OpenRead("preamble.wav")) - { - var response = await deepgram.Transcription.Prerecorded.GetTranscriptionAsync( - // UNCOMMENT IF USING LOCAL FILE: - // new Deepgram.Transcription.StreamSource( - // fs, - // "audio/wav"), - new Deepgram.Transcription.UrlSource("https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"), + { + DeepgramClient deepgram = new DeepgramClient(new Credentials(API_KEY)); + var response = await deepgram.Transcription.Prerecorded.GetTranscriptionAsync( + new UrlSource("https://www.happyhourspanish.com/wp-content/uploads/podcasts/HHS_Podcast_Soccer_Eurocup.mp3"), new PrerecordedTranscriptionOptions() { - Punctuate = true, - Utterances = true, + Summarize = "v2", + DetectLanguage = true }); - Console.WriteLine(JsonConvert.SerializeObject(response)); - } + Console.WriteLine(JsonConvert.SerializeObject(response)); } } } \ No newline at end of file diff --git a/SampleApp/SampleApp.csproj b/SampleApp/SampleApp.csproj index 79cafc58..63c7a471 100644 --- a/SampleApp/SampleApp.csproj +++ b/SampleApp/SampleApp.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 enable enable From 6a07f54268e69f645b57598f7de952d9e1d3b336 Mon Sep 17 00:00:00 2001 From: Sandra Rodgers Date: Wed, 19 Jul 2023 14:06:41 -0500 Subject: [PATCH 2/3] adds warning --- .../PrerecordedTranscriptionMetaData.cs | 8 ++++- Deepgram/Transcription/Warning.cs | 31 +++++++++++++++++++ Deepgram/Transcription/WarningType.cs | 23 ++++++++++++++ SampleApp/Program.cs | 2 +- 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Deepgram/Transcription/Warning.cs create mode 100644 Deepgram/Transcription/WarningType.cs diff --git a/Deepgram/Transcription/PrerecordedTranscriptionMetaData.cs b/Deepgram/Transcription/PrerecordedTranscriptionMetaData.cs index d6b10ae4..b17b5fe8 100644 --- a/Deepgram/Transcription/PrerecordedTranscriptionMetaData.cs +++ b/Deepgram/Transcription/PrerecordedTranscriptionMetaData.cs @@ -39,6 +39,12 @@ public class PrerecordedTranscriptionMetaData /// Number of channels detected in the submitted audio. /// [JsonProperty("channels")] - public int Channels { get; set; } + public int Channels { get; set; } + + /// + /// Warnings to provide feedback about unsupported and deprecated queries. + /// + [JsonProperty("warnings")] + public Warning[] Warnings { get; set; } } } diff --git a/Deepgram/Transcription/Warning.cs b/Deepgram/Transcription/Warning.cs new file mode 100644 index 00000000..58b9a24a --- /dev/null +++ b/Deepgram/Transcription/Warning.cs @@ -0,0 +1,31 @@ +using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Deepgram.Transcription +{ + public class Warning + { + /// + /// Parameter sent in the request that resulted in the warning + /// + [JsonProperty("parameter")] + public string Parameter { get; set; } + + /// + /// The type of warning + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public WarningType Type { get; set; } + + /// + /// The warning message + /// + [JsonProperty("message")] + public string Message { get; set; } + + } +} + + diff --git a/Deepgram/Transcription/WarningType.cs b/Deepgram/Transcription/WarningType.cs new file mode 100644 index 00000000..4c72635d --- /dev/null +++ b/Deepgram/Transcription/WarningType.cs @@ -0,0 +1,23 @@ +using System; +using System.Runtime.Serialization; + +namespace Deepgram.Transcription +{ + public enum WarningType + + { + [EnumMember(Value = "unsupported_language")] + UnsupportedLanguage, + + [EnumMember(Value = "unsupported_model")] + UnsupportedModel, + + [EnumMember(Value = "unsupported_encoding")] + UnsupportedEncoding, + + [EnumMember(Value = "deprecated")] + Deprecated +} +} + + diff --git a/SampleApp/Program.cs b/SampleApp/Program.cs index 736b2ae8..24ba6ce7 100644 --- a/SampleApp/Program.cs +++ b/SampleApp/Program.cs @@ -5,7 +5,7 @@ namespace SampleApp { class Program { - const string API_KEY = "24c13ac94b54bd2345dc5d5a93488de63d7d6531"; + const string API_KEY = ""; static async Task Main(string[] args) { From 264349fa8b20ad520eedf3b7565da12d35403100 Mon Sep 17 00:00:00 2001 From: Sandra Rodgers Date: Wed, 19 Jul 2023 14:17:20 -0500 Subject: [PATCH 3/3] formatting --- Deepgram/Transcription/Warning.cs | 38 +++++++++++++-------------- Deepgram/Transcription/WarningType.cs | 24 ++++++++--------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Deepgram/Transcription/Warning.cs b/Deepgram/Transcription/Warning.cs index 58b9a24a..f6413dfb 100644 --- a/Deepgram/Transcription/Warning.cs +++ b/Deepgram/Transcription/Warning.cs @@ -4,28 +4,28 @@ namespace Deepgram.Transcription { - public class Warning - { - /// - /// Parameter sent in the request that resulted in the warning - /// - [JsonProperty("parameter")] - public string Parameter { get; set; } + public class Warning + { + /// + /// Parameter sent in the request that resulted in the warning + /// + [JsonProperty("parameter")] + public string Parameter { get; set; } - /// - /// The type of warning - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public WarningType Type { get; set; } + /// + /// The type of warning + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public WarningType Type { get; set; } - /// - /// The warning message - /// - [JsonProperty("message")] - public string Message { get; set; } + /// + /// The warning message + /// + [JsonProperty("message")] + public string Message { get; set; } - } + } } diff --git a/Deepgram/Transcription/WarningType.cs b/Deepgram/Transcription/WarningType.cs index 4c72635d..3c9917bb 100644 --- a/Deepgram/Transcription/WarningType.cs +++ b/Deepgram/Transcription/WarningType.cs @@ -6,18 +6,18 @@ namespace Deepgram.Transcription public enum WarningType { - [EnumMember(Value = "unsupported_language")] - UnsupportedLanguage, - - [EnumMember(Value = "unsupported_model")] - UnsupportedModel, - - [EnumMember(Value = "unsupported_encoding")] - UnsupportedEncoding, - - [EnumMember(Value = "deprecated")] - Deprecated -} + [EnumMember(Value = "unsupported_language")] + UnsupportedLanguage, + + [EnumMember(Value = "unsupported_model")] + UnsupportedModel, + + [EnumMember(Value = "unsupported_encoding")] + UnsupportedEncoding, + + [EnumMember(Value = "deprecated")] + Deprecated + } }