diff --git a/Deepgram.Dev.sln b/Deepgram.Dev.sln index 11eb422a..c8379a58 100644 --- a/Deepgram.Dev.sln +++ b/Deepgram.Dev.sln @@ -97,6 +97,36 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "balances", "balances", "{7C EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\balances\Manage.csproj", "{2BF14C9B-755E-41FD-BB59-D6A82E0EFC51}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "debug", "debug", "{60E5C3AE-B377-4E53-B4CF-03D33839F382}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "streaming", "streaming", "{248ECFA2-D91E-4544-8B61-9D4410D90BEF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "tests\debug\streaming\Streaming.csproj", "{B488DC2B-02B2-46D7-9EA6-7033C1190878}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "invitations", "invitations", "{01445A10-0E4E-4457-A4CC-D071897D3FCF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "keys", "keys", "{1C04C4F8-3FC6-4487-8E48-779D2F223247}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "members", "members", "{25550C53-1E7F-46BF-9D94-3369A3A4E5A3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "projects", "projects", "{E7D50060-F040-4607-A0EF-34A4ABB4C770}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "usage", "usage", "{CB0677E6-85EC-47B9-A392-FF5B56484F15}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scopes", "scopes", "{6B24CAD4-8486-405C-B7EB-14086177C634}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\invitations\Manage.csproj", "{47017DCF-19C3-4692-8EB2-45DD9E6893CD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\keys\Manage.csproj", "{64436CDA-A428-44F8-8F16-B8CFD577DE04}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\members\Manage.csproj", "{FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\projects\Manage.csproj", "{0C82172F-6433-4089-919A-6CA7A54BAFA4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\scopes\Manage.csproj", "{A65BCE7D-761C-4D09-8E89-CEA461D7C832}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\usage\Manage.csproj", "{260D68E2-540F-4BFF-AF52-B014E7615795}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -183,6 +213,34 @@ Global {2BF14C9B-755E-41FD-BB59-D6A82E0EFC51}.Debug|Any CPU.Build.0 = Debug|Any CPU {2BF14C9B-755E-41FD-BB59-D6A82E0EFC51}.Release|Any CPU.ActiveCfg = Release|Any CPU {2BF14C9B-755E-41FD-BB59-D6A82E0EFC51}.Release|Any CPU.Build.0 = Release|Any CPU + {B488DC2B-02B2-46D7-9EA6-7033C1190878}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B488DC2B-02B2-46D7-9EA6-7033C1190878}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B488DC2B-02B2-46D7-9EA6-7033C1190878}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B488DC2B-02B2-46D7-9EA6-7033C1190878}.Release|Any CPU.Build.0 = Release|Any CPU + {47017DCF-19C3-4692-8EB2-45DD9E6893CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47017DCF-19C3-4692-8EB2-45DD9E6893CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47017DCF-19C3-4692-8EB2-45DD9E6893CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47017DCF-19C3-4692-8EB2-45DD9E6893CD}.Release|Any CPU.Build.0 = Release|Any CPU + {64436CDA-A428-44F8-8F16-B8CFD577DE04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64436CDA-A428-44F8-8F16-B8CFD577DE04}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64436CDA-A428-44F8-8F16-B8CFD577DE04}.Release|Any CPU.ActiveCfg = Release|Any CPU + {64436CDA-A428-44F8-8F16-B8CFD577DE04}.Release|Any CPU.Build.0 = Release|Any CPU + {FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}.Release|Any CPU.Build.0 = Release|Any CPU + {0C82172F-6433-4089-919A-6CA7A54BAFA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C82172F-6433-4089-919A-6CA7A54BAFA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C82172F-6433-4089-919A-6CA7A54BAFA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C82172F-6433-4089-919A-6CA7A54BAFA4}.Release|Any CPU.Build.0 = Release|Any CPU + {A65BCE7D-761C-4D09-8E89-CEA461D7C832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A65BCE7D-761C-4D09-8E89-CEA461D7C832}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A65BCE7D-761C-4D09-8E89-CEA461D7C832}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A65BCE7D-761C-4D09-8E89-CEA461D7C832}.Release|Any CPU.Build.0 = Release|Any CPU + {260D68E2-540F-4BFF-AF52-B014E7615795}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {260D68E2-540F-4BFF-AF52-B014E7615795}.Debug|Any CPU.Build.0 = Debug|Any CPU + {260D68E2-540F-4BFF-AF52-B014E7615795}.Release|Any CPU.ActiveCfg = Release|Any CPU + {260D68E2-540F-4BFF-AF52-B014E7615795}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -230,6 +288,21 @@ Global {FA5723B3-74E9-4221-80EF-4833C1C3DD9F} = {C673DFD1-528A-4BAE-94E6-02EF058AC363} {7CD5D816-0F30-45D7-9C9F-872E67F6A711} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F} {2BF14C9B-755E-41FD-BB59-D6A82E0EFC51} = {7CD5D816-0F30-45D7-9C9F-872E67F6A711} + {60E5C3AE-B377-4E53-B4CF-03D33839F382} = {9D2B336D-17F9-41D5-A4E5-F3EDA7F496A5} + {248ECFA2-D91E-4544-8B61-9D4410D90BEF} = {60E5C3AE-B377-4E53-B4CF-03D33839F382} + {B488DC2B-02B2-46D7-9EA6-7033C1190878} = {248ECFA2-D91E-4544-8B61-9D4410D90BEF} + {01445A10-0E4E-4457-A4CC-D071897D3FCF} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F} + {1C04C4F8-3FC6-4487-8E48-779D2F223247} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F} + {25550C53-1E7F-46BF-9D94-3369A3A4E5A3} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F} + {E7D50060-F040-4607-A0EF-34A4ABB4C770} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F} + {CB0677E6-85EC-47B9-A392-FF5B56484F15} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F} + {6B24CAD4-8486-405C-B7EB-14086177C634} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F} + {47017DCF-19C3-4692-8EB2-45DD9E6893CD} = {01445A10-0E4E-4457-A4CC-D071897D3FCF} + {64436CDA-A428-44F8-8F16-B8CFD577DE04} = {1C04C4F8-3FC6-4487-8E48-779D2F223247} + {FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC} = {25550C53-1E7F-46BF-9D94-3369A3A4E5A3} + {0C82172F-6433-4089-919A-6CA7A54BAFA4} = {E7D50060-F040-4607-A0EF-34A4ABB4C770} + {A65BCE7D-761C-4D09-8E89-CEA461D7C832} = {6B24CAD4-8486-405C-B7EB-14086177C634} + {260D68E2-540F-4BFF-AF52-B014E7615795} = {CB0677E6-85EC-47B9-A392-FF5B56484F15} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8D4ABC6D-7126-4EE2-9303-43A954616B2A} diff --git a/Deepgram/Models/Manage/v1/Details.cs b/Deepgram/Models/Manage/v1/Details.cs index f6b92224..bd4fd9aa 100644 --- a/Deepgram/Models/Manage/v1/Details.cs +++ b/Deepgram/Models/Manage/v1/Details.cs @@ -22,7 +22,7 @@ public record Details /// Number of audio files processed in the request. /// [JsonPropertyName("total_audio")] - public int? TotalAudio { get; set; } + public double? TotalAudio { get; set; } /// /// Number of channels in the audio associated with the request. diff --git a/Deepgram/Models/Manage/v1/InviteSchema.cs b/Deepgram/Models/Manage/v1/InviteSchema.cs index b7b19c95..f7b198f3 100644 --- a/Deepgram/Models/Manage/v1/InviteSchema.cs +++ b/Deepgram/Models/Manage/v1/InviteSchema.cs @@ -4,18 +4,18 @@ namespace Deepgram.Models.Manage.v1; -public class InviteSchema(string email, string scope) +public class InviteSchema { /// /// email of the person being invited /// [JsonPropertyName("email")] - public string? Email { get; set; } = email; + public string? Email { get; set; } /// /// scopes to add for the invited person /// [JsonPropertyName("scope")] - public string? Scope { get; set; } = scope; + public string? Scope { get; set; } } diff --git a/Deepgram/Models/Manage/v1/KeySchema.cs b/Deepgram/Models/Manage/v1/KeySchema.cs index b959eb7f..cd53e21c 100644 --- a/Deepgram/Models/Manage/v1/KeySchema.cs +++ b/Deepgram/Models/Manage/v1/KeySchema.cs @@ -4,20 +4,20 @@ namespace Deepgram.Models.Manage.v1; -public class KeySchema(string comment, List scopes) +public class KeySchema { /// /// Comment to describe key /// [JsonPropertyName("comment")] - public string? Comment { get; set; } = comment; + public string? Comment { get; set; } /// /// Scopes of the key /// [JsonPropertyName("scopes")] - public List? Scopes { get; set; } = scopes; + public List? Scopes { get; set; } /// /// Tag names for key diff --git a/Deepgram/Models/Manage/v1/MemberScopeSchema.cs b/Deepgram/Models/Manage/v1/MemberScopeSchema.cs index 409fe7db..4a194ede 100644 --- a/Deepgram/Models/Manage/v1/MemberScopeSchema.cs +++ b/Deepgram/Models/Manage/v1/MemberScopeSchema.cs @@ -4,11 +4,11 @@ namespace Deepgram.Models.Manage.v1; -public class MemberScopeSchema(string scope) +public class MemberScopeSchema { /// /// Scope to add for member /// [JsonPropertyName("scope")] - public string? Scope { get; set; } = scope; + public string? Scope { get; set; } } diff --git a/Deepgram/Models/Manage/v1/UsageFieldsResponse.cs b/Deepgram/Models/Manage/v1/UsageFieldsResponse.cs index 38a547ec..74040309 100644 --- a/Deepgram/Models/Manage/v1/UsageFieldsResponse.cs +++ b/Deepgram/Models/Manage/v1/UsageFieldsResponse.cs @@ -22,8 +22,8 @@ public record UsageFieldsResponse /// ReadOnlyList of /// [JsonPropertyName("processing_methods")] - [JsonConverter(typeof(JsonStringEnumConverter))] - public IReadOnlyList? ProcessingMethods { get; set; } + //[JsonConverter(typeof(JsonStringEnumConverter))] + public IReadOnlyList? ProcessingMethods { get; set; } /// /// ReadOnlyList of included languages diff --git a/Deepgram/Models/PreRecorded/v1/Channel.cs b/Deepgram/Models/PreRecorded/v1/Channel.cs index 989ffce6..ea83c9c8 100644 --- a/Deepgram/Models/PreRecorded/v1/Channel.cs +++ b/Deepgram/Models/PreRecorded/v1/Channel.cs @@ -3,6 +3,7 @@ // SPDX-License-Identifier: MIT namespace Deepgram.Models.PreRecorded.v1; + public record Channel { /// diff --git a/Deepgram/Models/PreRecorded/v1/IntentSchema.cs b/Deepgram/Models/PreRecorded/v1/IntentSchema.cs deleted file mode 100644 index 77660066..00000000 --- a/Deepgram/Models/PreRecorded/v1/IntentSchema.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021-2024 Deepgram .NET SDK contributors. All Rights Reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. -// SPDX-License-Identifier: MIT - -namespace Deepgram.Models.PreRecorded.v1; - -public class IntentSchema -{ - /// - /// Enables intent recognition - /// - [JsonPropertyName("intents")] - public bool? Intents { get; set; } - - /// - /// The language of your input audio (Only english is supported at this time) - /// - [JsonPropertyName("language")] - public string? Language { get; set; } = "en"; - - /// - /// Optional. A custom intent you want the model to detect within your input audio if present. Submit up to 100. - /// - [JsonPropertyName("custom_intent")] - public string? CustomIntent { get; set; } - - /// - /// Optional. Sets how the model will interpret strings submitted to the custom_intent param. When "strict", the model will only return intents submitted using the custom_intent param. When "extended", the model will return it's own detected intents in addition those submitted using the custom_intents param. - /// - [JsonPropertyName("custom_intent_mode")] - public string? CustomIntentMode { get; set; } -} diff --git a/examples/analyze/intent/Program.cs b/examples/analyze/intent/Program.cs index b778ce4c..62a1c824 100644 --- a/examples/analyze/intent/Program.cs +++ b/examples/analyze/intent/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new AnalyzeClient(); @@ -35,7 +41,7 @@ static async Task Main(string[] args) Intents = true, }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine($"\n\n{JsonSerializer.Serialize(response, options)}\n\n"); Console.ReadKey(); // Teardown Library diff --git a/examples/analyze/sentiment/Program.cs b/examples/analyze/sentiment/Program.cs index 7312ff85..b9f35d6d 100644 --- a/examples/analyze/sentiment/Program.cs +++ b/examples/analyze/sentiment/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new AnalyzeClient(); @@ -35,7 +41,7 @@ static async Task Main(string[] args) Sentiment = true, }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine(JsonSerializer.Serialize(response, options)); Console.ReadKey(); // Teardown Library diff --git a/examples/analyze/summary/Program.cs b/examples/analyze/summary/Program.cs index d848fdec..9e4446d9 100644 --- a/examples/analyze/summary/Program.cs +++ b/examples/analyze/summary/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new AnalyzeClient(); @@ -35,7 +41,7 @@ static async Task Main(string[] args) Summarize = true, }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine(JsonSerializer.Serialize(response, options)); Console.ReadKey(); // Teardown Library diff --git a/examples/analyze/topic/Program.cs b/examples/analyze/topic/Program.cs index 47a45070..d5c842b7 100644 --- a/examples/analyze/topic/Program.cs +++ b/examples/analyze/topic/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new AnalyzeClient(); @@ -35,7 +41,7 @@ static async Task Main(string[] args) Topics = true, }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine(JsonSerializer.Serialize(response, options)); Console.ReadKey(); // Teardown Library diff --git a/examples/manage/balances/Program.cs b/examples/manage/balances/Program.cs index cbdc63cf..81e7b6c8 100644 --- a/examples/manage/balances/Program.cs +++ b/examples/manage/balances/Program.cs @@ -19,6 +19,12 @@ static async Task Main(string[] args) // OR very chatty logging //Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new ManageClient(); @@ -28,48 +34,41 @@ static async Task Main(string[] args) Console.WriteLine("No projects found."); return; } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(response, options)}\n\n"); - Console.WriteLine(JsonSerializer.Serialize(response)); - - //var projectId = ""; - //foreach (var project in response.Projects) - //{ - // Console.WriteLine($"Project ID: {project.ProjectId}"); - // projectId = project.ProjectId; - // break; - //} - - //var balanacesResponse = deepgramClient.GetBalances(projectId); - //if (balanacesResponse == null || balanacesResponse.Balances == null) - //{ - // Console.WriteLine("No balance found."); - // return; - //} - - //Console.WriteLine("\n\nBalances:"); - //Console.WriteLine(JsonSerializer.Serialize(balanacesResponse)); - //Console.WriteLine("\n\n"); + var projectId = ""; + foreach (var project in response.Projects) + { + Console.WriteLine($"Using Project ID: {project.ProjectId}"); + projectId = project.ProjectId; + break; + } - //string balanceId = ""; - //foreach (var balance in balanacesResponse.Balances) - //{ - // Console.WriteLine($"Balance ID: {balance.BalanceId}"); - // balanceId = balance.BalanceId; - // break; - //} + var balanacesResponse = deepgramClient.GetBalances(projectId); + if (balanacesResponse == null) + { + Console.WriteLine("\n\nNo balance found.\n\n"); + return; + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(balanacesResponse, options)}\n\n"); - //var balanaceResponse = deepgramClient.GetBalance(projectId, balanceId); - //if (balanaceResponse == null) - //{ - // Console.WriteLine("No balance found."); - // return; - //} + string balanceId = ""; + foreach (var balance in balanacesResponse.Result.Balances) + { + Console.WriteLine($"Using Balance ID: {balance.BalanceId}"); + balanceId = balance.BalanceId; + break; + } - //Console.WriteLine("\n\nBalances:"); - //Console.WriteLine(JsonSerializer.Serialize(balanacesResponse)); - //Console.WriteLine("\n\n"); + var balanceResponse = deepgramClient.GetBalance(projectId, balanceId); + if (balanceResponse == null) + { + Console.WriteLine("\n\nNo balance found.\n\n"); + return; + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(balanceResponse, options)}\n\n"); - Console.WriteLine("Press any key to exit."); + Console.WriteLine("\n\nPress any key to exit."); Console.ReadKey(); // Teardown Library diff --git a/examples/manage/invitations/Manage.csproj b/examples/manage/invitations/Manage.csproj new file mode 100644 index 00000000..33d8f4ee --- /dev/null +++ b/examples/manage/invitations/Manage.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/examples/manage/invitations/Program.cs b/examples/manage/invitations/Program.cs new file mode 100644 index 00000000..8aadc4bb --- /dev/null +++ b/examples/manage/invitations/Program.cs @@ -0,0 +1,107 @@ +// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +using System.Text.Json; + +using Deepgram.Logger; +using Deepgram.Models.Manage.v1; + +namespace SampleApp +{ + class Program + { + static async Task Main(string[] args) + { + // Initialize Library with default logging + // Normal logging is "Info" level + Library.Initialize(); + // OR very chatty logging + //Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose + + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key + var deepgramClient = new ManageClient(); + + // get projects + var projectResp = await deepgramClient.GetProjects(); + if (projectResp == null) + { + Console.WriteLine("ListProjects failed."); + Environment.Exit(1); + } + + string myId = null; + string myName = null; + foreach (var project in projectResp.Projects) + { + myId = project.ProjectId; + myName = project.Name; + Console.WriteLine($"\n\nListProjects() - ID: {myId}, Name: {myName}\n\n"); + break; + } + + // list invites + var listResp = await deepgramClient.GetInvites(myId); + if (listResp.Invites.Count == 0) + { + Console.WriteLine("\n\nNo invites found\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + } + + // send invite + var createInvite = new InviteSchema() + { + Email = "spam@spam.com", + Scope = "member", + }; + + var createResp = await deepgramClient.SendInvite(myId, createInvite); + Console.WriteLine($"\n\n{JsonSerializer.Serialize(createResp, options)}\n\n"); + + // list invites + listResp = await deepgramClient.GetInvites(myId); + if (listResp == null) + { + Console.WriteLine("\n\nNo invites found\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + } + + // delete invite + var delResp = await deepgramClient.DeleteInvite(myId, "spam@spam.com"); + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + + // list invites + listResp = await deepgramClient.GetInvites(myId); + if (listResp == null) + { + Console.WriteLine("\n\nNo invites found\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + } + + // Leave commented out unless you are running this from a secondary account + //var leaveResp = await deepgramClient.LeaveProject(myId); + //Console.WriteLine($"\n\n{JsonSerializer.Serialize(leaveResp, options)}\n\n"); + + Console.WriteLine("\n\nPress any key to exit."); + Console.ReadKey(); + + // Teardown Library + Library.Terminate(); + } + } +} \ No newline at end of file diff --git a/examples/manage/keys/Manage.csproj b/examples/manage/keys/Manage.csproj new file mode 100644 index 00000000..33d8f4ee --- /dev/null +++ b/examples/manage/keys/Manage.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/examples/manage/keys/Program.cs b/examples/manage/keys/Program.cs new file mode 100644 index 00000000..1c0e0ce6 --- /dev/null +++ b/examples/manage/keys/Program.cs @@ -0,0 +1,134 @@ +// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +using System.Text.Json; + +using Deepgram.Logger; +using Deepgram.Models.Manage.v1; + +namespace SampleApp +{ + class Program + { + static async Task Main(string[] args) + { + // Initialize Library with default logging + // Normal logging is "Info" level + Library.Initialize(); + // OR very chatty logging + //Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose + + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key + var deepgramClient = new ManageClient(); + + // get projects + var projectResp = await deepgramClient.GetProjects(); + if (projectResp == null) + { + Console.WriteLine("ListProjects failed."); + Environment.Exit(1); + } + + string myId = null; + string myName = null; + foreach (var project in projectResp.Projects) + { + myId = project.ProjectId; + myName = project.Name; + Console.WriteLine($"ListProjects() - ID: {myId}, Name: {myName}"); + break; + } + + // list keys + var listResp = await deepgramClient.GetKeys(myId); + if (listResp == null) + { + Console.WriteLine("\n\nNo keys found\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + } + + // create key + var createKey = new KeySchema() + { + Comment = "MyTestKey", + Scopes = new List { "member" }, + }; + + string myKeyId = null; + var createResp = await deepgramClient.CreateKey(myId, createKey); + if (createResp == null) + { + Console.WriteLine("\n\nCreateKey failed.\n\n"); + Environment.Exit(1); + } + else + { + myKeyId = createResp.ApiKeyId; + Console.WriteLine($"\n\n{JsonSerializer.Serialize(createResp, options)}\n\n"); + } + + // list keys + listResp = await deepgramClient.GetKeys(myId); + if (listResp == null) + { + Console.WriteLine("\n\nNo keys found\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + } + + // get key + var getResp = await deepgramClient.GetKey(myId, myKeyId); + if (getResp == null) + { + Console.WriteLine("\n\nGetKey failed.\n\n"); + Environment.Exit(1); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(getResp, options)}\n\n"); + } + + // delete key + var deleteResp = await deepgramClient.DeleteKey(myId, myKeyId); + if (deleteResp == null) + { + Console.WriteLine("\n\nDeleteKey failed.\n\n"); + Environment.Exit(1); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(deleteResp, options)}\n\n"); + } + + // list keys + listResp = await deepgramClient.GetKeys(myId); + if (listResp == null) + { + Console.WriteLine("\n\nNo keys found\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + } + + + Console.WriteLine("\n\nPress any key to exit."); + Console.ReadKey(); + + // Teardown Library + Library.Terminate(); + } + } +} \ No newline at end of file diff --git a/examples/manage/members/Manage.csproj b/examples/manage/members/Manage.csproj new file mode 100644 index 00000000..33d8f4ee --- /dev/null +++ b/examples/manage/members/Manage.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/examples/manage/members/Program.cs b/examples/manage/members/Program.cs new file mode 100644 index 00000000..0a395966 --- /dev/null +++ b/examples/manage/members/Program.cs @@ -0,0 +1,109 @@ +// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +using System.Text.Json; + +using Deepgram.Logger; +using Deepgram.Models.Manage.v1; + +namespace SampleApp +{ + class Program + { + private const string DELETE_MEMBER_BY_EMAIL = "MY_EMAIL"; + + static async Task Main(string[] args) + { + // Initialize Library with default logging + // Normal logging is "Info" level + Library.Initialize(); + // OR very chatty logging + //Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose + + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key + var deepgramClient = new ManageClient(); + + // Get projects + var projectResp = deepgramClient.GetProjects(); + if (projectResp == null) + { + Console.WriteLine("ListProjects failed."); + Environment.Exit(1); + } + + string myId = null; + foreach (var project in projectResp.Result.Projects) + { + myId = project.ProjectId; + string myName = project.Name; + Console.WriteLine($"\n\nListProjects() - ID: {myId}, Name: {myName}\n\n"); + } + + // List members + string delMemberId = null; + var listResp = deepgramClient.GetMembers(myId); + if (listResp == null) + { + Console.WriteLine("No members found"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + + foreach (var member in listResp.Result.Members) + { + if (member.Email == DELETE_MEMBER_BY_EMAIL) + { + delMemberId = member.MemberId; + } + } + } + + // Delete member + if (delMemberId == null) + { + Console.WriteLine(""); + Console.WriteLine("This example requires a project that already exists with a name specified in DELETE_MEMBER_BY_EMAIL."); + Console.WriteLine("This is required to exercise the RemoveMember function."); + Console.WriteLine("In the absence of this, this example will exit early."); + Console.WriteLine(""); + Environment.Exit(1); + } + + var deleteResp = deepgramClient.RemoveMember(myId, delMemberId); + if (deleteResp == null) + { + Console.WriteLine("\n\nRemoveMember failed.\n\n"); + Environment.Exit(1); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + } + + // List members + listResp = deepgramClient.GetMembers(myId); + if (listResp == null) + { + Console.WriteLine("\n\nNo members found.\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + } + + Console.WriteLine("\n\nPress any key to exit."); + Console.ReadKey(); + + // Teardown Library + Library.Terminate(); + } + } +} \ No newline at end of file diff --git a/examples/manage/projects/Manage.csproj b/examples/manage/projects/Manage.csproj new file mode 100644 index 00000000..33d8f4ee --- /dev/null +++ b/examples/manage/projects/Manage.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/examples/manage/projects/Program.cs b/examples/manage/projects/Program.cs new file mode 100644 index 00000000..8691e7fb --- /dev/null +++ b/examples/manage/projects/Program.cs @@ -0,0 +1,130 @@ +// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +using System.Text.Json; + +using Deepgram.Logger; +using Deepgram.Models.Manage.v1; + +namespace SampleApp +{ + class Program + { + private const string DELETE_PROJECT_BY_NAME = "DELETE_PROJECT_NAME"; + + static async Task Main(string[] args) + { + // Initialize Library with default logging + // Normal logging is "Info" level + Library.Initialize(); + // OR very chatty logging + //Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose + + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key + var deepgramClient = new ManageClient(); + + // get projects + var listResp = await deepgramClient.GetProjects(); + if (listResp == null) + { + Console.WriteLine("ListProjects failed."); + Environment.Exit(1); + } + + string myId = null; + string myName = null; + string myDeleteId = null; + foreach (var project in listResp.Projects) + { + if (project.Name == DELETE_PROJECT_BY_NAME) + { + myDeleteId = project.ProjectId; + } + myId = project.ProjectId; + myName = project.Name; + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + + // get project + var getResp = await deepgramClient.GetProject(myId); + Console.WriteLine($"\n\n{JsonSerializer.Serialize(getResp, options)}\n\n"); + + // update project + var updateOptions = new ProjectSchema() + { + Name = "My TEST RENAME Example" + }; + + var updateResp = await deepgramClient.UpdateProject(myId, updateOptions); + if (updateResp == null) + { + Console.WriteLine("\n\nUpdateProject failed.\n\n"); + Environment.Exit(1); + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(updateResp, options)}\n\n"); + + // get project + getResp = await deepgramClient.GetProject(myId); + if (getResp == null) + { + Console.WriteLine("\n\nGetProject failed.\n\n"); + Environment.Exit(1); + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(getResp, options)}\n\n"); + + // update project + updateOptions = new ProjectSchema() + { + Name = myName, + }; + updateResp = await deepgramClient.UpdateProject(myId, updateOptions); + if (updateResp == null) + { + Console.WriteLine("\n\nUpdateProject failed.\n\n"); + Environment.Exit(1); + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(updateResp, options)}\n\n"); + + // get project + getResp = await deepgramClient.GetProject(myId); + if (getResp == null) + { + Console.WriteLine("\n\nGetProject failed.\n\n"); + Environment.Exit(1); + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(getResp, options)}\n\n"); + + // delete project + if (myDeleteId == null) + { + Console.WriteLine(""); + Console.WriteLine("This example requires a project who already exists who name is in the value \"DELETE_PROJECT_ID\"."); + Console.WriteLine("This is required to exercise the UpdateProject and DeleteProject function."); + Console.WriteLine("In the absence of this, this example will exit early."); + Console.WriteLine(""); + Environment.Exit(1); + } + + var respDelete = await deepgramClient.DeleteProject(myDeleteId); + if (respDelete == null) + { + Console.WriteLine("\n\nDeleteProject failed.\n\n"); + Environment.Exit(1); + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(respDelete, options)}\n\n"); + + Console.WriteLine("\n\nPress any key to exit."); + Console.ReadKey(); + + // Teardown Library + Library.Terminate(); + } + } +} \ No newline at end of file diff --git a/examples/manage/scopes/Manage.csproj b/examples/manage/scopes/Manage.csproj new file mode 100644 index 00000000..33d8f4ee --- /dev/null +++ b/examples/manage/scopes/Manage.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/examples/manage/scopes/Program.cs b/examples/manage/scopes/Program.cs new file mode 100644 index 00000000..ff6a851a --- /dev/null +++ b/examples/manage/scopes/Program.cs @@ -0,0 +1,130 @@ +// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +using System.Text.Json; + +using Deepgram.Logger; +using Deepgram.Models.Manage.v1; + +namespace SampleApp +{ + class Program + { + private const string MEMBER_BY_EMAIL = "MEMBER_TO_DELETE_BY_EMAIL"; + + static async Task Main(string[] args) + { + // Initialize Library with default logging + // Normal logging is "Info" level + Library.Initialize(); + // OR very chatty logging + //Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose + + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key + var deepgramClient = new ManageClient(); + + // get projects + var projectResp = await deepgramClient.GetProjects(); + if (projectResp == null) + { + Console.WriteLine("ListProjects failed."); + Environment.Exit(1); + } + + string myId = null; + string myName = null; + foreach (var project in projectResp.Projects) + { + myId = project.ProjectId; + myName = project.Name; + break; + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(projectResp, options)}\n\n"); + + // list members + string memberId = null; + var listResp = await deepgramClient.GetMembers(myId); + if (listResp == null) + { + Console.WriteLine("\n\nNo members found\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + + foreach (var member in listResp.Members) + { + if (member.Email == MEMBER_BY_EMAIL) + { + memberId = member.MemberId; + } + } + } + + if (memberId == null) + { + Console.WriteLine("This example requires a member who is already a member with email in the value of \"MEMBER_BY_EMAIL\"."); + Console.WriteLine("This is required to exercise the UpdateMemberScope function."); + Console.WriteLine("In the absence of this, this example will exit early."); + Environment.Exit(1); + } + + // get member scope + var memberResp = await deepgramClient.GetMemberScopes(myId, memberId); + if (memberResp == null) + { + Console.WriteLine("\n\nNo scopes found\n\n"); + Environment.Exit(1); + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(memberResp, options)}\n\n"); + + // update scope + var scopeUpdate = new MemberScopeSchema() + { + Scope = "admin" + }; + var updateResp = await deepgramClient.UpdateMemberScope(myId, memberId, scopeUpdate); + Console.WriteLine($"\n\n{JsonSerializer.Serialize(updateResp, options)}\n\n"); + + // get member scope + memberResp = await deepgramClient.GetMemberScopes(myId, memberId); + if (memberResp == null) + { + Console.WriteLine("\n\nNo scopes found\n\n"); + Environment.Exit(1); + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(memberResp, options)}\n\n"); + + // update scope + scopeUpdate = new MemberScopeSchema() + { + Scope = "member", + }; + updateResp = await deepgramClient.UpdateMemberScope(myId, memberId, scopeUpdate); + Console.WriteLine($"\n\n{JsonSerializer.Serialize(updateResp, options)}\n\n"); + + // get member scope + memberResp = await deepgramClient.GetMemberScopes(myId, memberId); + if (memberResp == null) + { + Console.WriteLine("\n\nNo scopes found\n\n"); + Environment.Exit(1); + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(memberResp, options)}\n\n"); + + + Console.WriteLine("\n\nPress any key to exit."); + Console.ReadKey(); + + // Teardown Library + Library.Terminate(); + } + } +} \ No newline at end of file diff --git a/examples/manage/usage/Manage.csproj b/examples/manage/usage/Manage.csproj new file mode 100644 index 00000000..33d8f4ee --- /dev/null +++ b/examples/manage/usage/Manage.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/examples/manage/usage/Program.cs b/examples/manage/usage/Program.cs new file mode 100644 index 00000000..85c7f08b --- /dev/null +++ b/examples/manage/usage/Program.cs @@ -0,0 +1,113 @@ +// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +using System.Text.Json; + +using Deepgram.Logger; +using Deepgram.Models.Manage.v1; + +namespace SampleApp +{ + class Program + { + static async Task Main(string[] args) + { + // Initialize Library with default logging + // Normal logging is "Info" level + Library.Initialize(); + // OR very chatty logging + //Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose + + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key + var deepgramClient = new ManageClient(); + + // get projects + var projectResp = await deepgramClient.GetProjects(); + if (projectResp == null) + { + Console.WriteLine("ListProjects failed."); + Environment.Exit(1); + } + + string myId = null; + string myName = null; + foreach (var project in projectResp.Projects) + { + myId = project.ProjectId; + myName = project.Name; + break; + } + Console.WriteLine($"\n\n{JsonSerializer.Serialize(projectResp, options)}\n\n"); + + // list requests + string requestId = null; + var requestsOptions = new UsageRequestsSchema(); + var listResp = await deepgramClient.GetUsageRequests(myId, requestsOptions); + if (listResp == null) + { + Console.WriteLine("\n\nNo requests found\n\n"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(listResp, options)}\n\n"); + + foreach (var request in listResp.Requests) + { + requestId = request.RequestId; + break; + } + } + Console.WriteLine($"request_id: {requestId}\n\n"); + + // get request + var reqResp = await deepgramClient.GetUsageRequest(myId, requestId); + if (reqResp == null) + { + Console.WriteLine("No request found"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(reqResp, options)}\n\n"); + } + + // get fields + var fieldsOptions = new UsageFieldsSchema(); + var fieldsResp = await deepgramClient.GetUsageFields(myId, fieldsOptions); + if (fieldsResp == null) + { + Console.WriteLine("UsageFields not found."); + Environment.Exit(1); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(fieldsResp, options)}\n\n"); + } + + // list usage + var summaryOptions = new UsageSummarySchema(); + var summaryResp = await deepgramClient.GetUsageSummary(myId, summaryOptions); + if (summaryResp == null) + { + Console.WriteLine("UsageSummary not found"); + } + else + { + Console.WriteLine($"\n\n{JsonSerializer.Serialize(summaryResp, options)}\n\n"); + } + + + Console.WriteLine("\n\nPress any key to exit."); + Console.ReadKey(); + + // Teardown Library + Library.Terminate(); + } + } +} \ No newline at end of file diff --git a/examples/prerecorded/file/Program.cs b/examples/prerecorded/file/Program.cs index 10993235..e35bce1b 100644 --- a/examples/prerecorded/file/Program.cs +++ b/examples/prerecorded/file/Program.cs @@ -3,7 +3,6 @@ // SPDX-License-Identifier: MIT using System.Text.Json; - using Deepgram.Logger; using Deepgram.Models.PreRecorded.v1; @@ -19,6 +18,12 @@ static async Task Main(string[] args) // OR very chatty logging //Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new PreRecordedClient(); @@ -38,7 +43,7 @@ static async Task Main(string[] args) Punctuate = true, }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine($"\n\n{JsonSerializer.Serialize(response, options)}\n\n"); Console.ReadKey(); // Teardown Library diff --git a/examples/prerecorded/intent/Program.cs b/examples/prerecorded/intent/Program.cs index f8a43348..b615467f 100644 --- a/examples/prerecorded/intent/Program.cs +++ b/examples/prerecorded/intent/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new PreRecordedClient(); @@ -36,7 +42,7 @@ static async Task Main(string[] args) Intents = true, }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine(JsonSerializer.Serialize(response, options)); Console.ReadKey(); // Teardown Library diff --git a/examples/prerecorded/sentiment/Program.cs b/examples/prerecorded/sentiment/Program.cs index f47ef6f8..cecdfe05 100644 --- a/examples/prerecorded/sentiment/Program.cs +++ b/examples/prerecorded/sentiment/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new PreRecordedClient(); @@ -37,7 +43,7 @@ static async Task Main(string[] args) Sentiment = true, }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine(JsonSerializer.Serialize(response, options)); Console.ReadKey(); // Teardown Library diff --git a/examples/prerecorded/summary/Program.cs b/examples/prerecorded/summary/Program.cs index 8cb445c1..a54c28ed 100644 --- a/examples/prerecorded/summary/Program.cs +++ b/examples/prerecorded/summary/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new PreRecordedClient(); @@ -36,7 +42,7 @@ static async Task Main(string[] args) Summarize = "v2", }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine(JsonSerializer.Serialize(response, options)); Console.ReadKey(); // Teardown Library diff --git a/examples/prerecorded/topic/Program.cs b/examples/prerecorded/topic/Program.cs index d5b9914b..f78349a2 100644 --- a/examples/prerecorded/topic/Program.cs +++ b/examples/prerecorded/topic/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new PreRecordedClient(); @@ -36,7 +42,7 @@ static async Task Main(string[] args) Topics = true, }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine(JsonSerializer.Serialize(response, options)); Console.ReadKey(); // Teardown Library diff --git a/examples/prerecorded/url/Program.cs b/examples/prerecorded/url/Program.cs index b82b131a..02ea3897 100644 --- a/examples/prerecorded/url/Program.cs +++ b/examples/prerecorded/url/Program.cs @@ -16,6 +16,12 @@ static async Task Main(string[] args) // Normal logging is "Info" level Library.Initialize(); + // JSON options + JsonSerializerOptions options = new(JsonSerializerDefaults.Web) + { + WriteIndented = true + }; + // Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key var deepgramClient = new PreRecordedClient(); @@ -26,7 +32,7 @@ static async Task Main(string[] args) Model = "nova-2", }); - Console.WriteLine(JsonSerializer.Serialize(response)); + Console.WriteLine(JsonSerializer.Serialize(response, options)); Console.ReadKey(); // Teardown Library diff --git a/examples/streaming/file/Program.cs b/examples/streaming/file/Program.cs index 9d82a6b9..73a06415 100644 --- a/examples/streaming/file/Program.cs +++ b/examples/streaming/file/Program.cs @@ -29,7 +29,7 @@ static async Task Main(string[] args) } // Console.WriteLine("Transcription received: " + JsonSerializer.Serialize(e.Transcription)); - Console.WriteLine($"\n\n\n----> Speaker: {e.Channel.Alternatives[0].Transcript}\n\n\n"); + Console.WriteLine($"\n\n\nSpeaker: {e.Channel.Alternatives[0].Transcript}\n\n\n"); })); // Start the connection diff --git a/examples/streaming/microphone/Program.cs b/examples/streaming/microphone/Program.cs index 37f2dff6..e4cca38d 100644 --- a/examples/streaming/microphone/Program.cs +++ b/examples/streaming/microphone/Program.cs @@ -42,7 +42,7 @@ static async Task Main(string[] args) })); liveClient.Subscribe(new EventHandler((sender, e) => { - if (e.Channel.Alternatives[0].Transcript == "") + if (e.Channel.Alternatives[0].Transcript.Trim() == "") { return; }