From fb4e9d4892111677f2a192ca261c15c67113c06d Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 19:04:26 +0000 Subject: [PATCH 1/2] SDK regeneration --- src/AssemblyAI/Core/Constants.cs | 1 + src/AssemblyAI/Core/Extensions.cs | 14 ++ src/AssemblyAI/Core/HeaderValue.cs | 17 ++ src/AssemblyAI/Core/Headers.cs | 17 ++ .../Core/Public/AssemblyAIException.cs | 9 +- src/AssemblyAI/Core/Public/ClientOptions.cs | 28 ++- src/AssemblyAI/Core/Public/RequestOptions.cs | 6 + src/AssemblyAI/Core/RawClient.cs | 52 +++-- src/AssemblyAI/Files/FilesClient.cs | 12 +- src/AssemblyAI/Files/Types/UploadedFile.cs | 6 + src/AssemblyAI/Lemur/LemurClient.cs | 131 ++++++++++-- .../Lemur/Requests/LemurActionItemsParams.cs | 5 + .../Requests/LemurQuestionAnswerParams.cs | 5 + .../Lemur/Requests/LemurSummaryParams.cs | 5 + .../Lemur/Requests/LemurTaskParams.cs | 5 + .../Lemur/Types/LemurActionItemsResponse.cs | 6 + src/AssemblyAI/Lemur/Types/LemurBaseParams.cs | 5 + .../Lemur/Types/LemurBaseResponse.cs | 6 + src/AssemblyAI/Lemur/Types/LemurModel.cs | 2 +- src/AssemblyAI/Lemur/Types/LemurQuestion.cs | 5 + .../Lemur/Types/LemurQuestionAnswer.cs | 6 + .../Types/LemurQuestionAnswerResponse.cs | 6 + .../Lemur/Types/LemurStringResponse.cs | 6 + .../Lemur/Types/LemurSummaryResponse.cs | 6 + .../Lemur/Types/LemurTaskResponse.cs | 6 + src/AssemblyAI/Lemur/Types/LemurUsage.cs | 6 + .../Types/PurgeLemurRequestDataResponse.cs | 6 + src/AssemblyAI/Realtime/RealtimeClient.cs | 16 +- .../CreateRealtimeTemporaryTokenParams.cs | 6 + .../Realtime/Types/AudioEncoding.cs | 2 +- .../ConfigureEndUtteranceSilenceThreshold.cs | 6 + .../Realtime/Types/FinalTranscript.cs | 6 + src/AssemblyAI/Realtime/Types/MessageType.cs | 2 +- .../Realtime/Types/PartialTranscript.cs | 6 + src/AssemblyAI/Realtime/Types/Realtime.cs | 17 ++ .../Realtime/Types/RealtimeBaseMessage.cs | 6 + .../Realtime/Types/RealtimeBaseTranscript.cs | 6 + .../Realtime/Types/RealtimeError.cs | 6 + .../Types/RealtimeTemporaryTokenResponse.cs | 6 + .../Realtime/Types/RealtimeTranscriptType.cs | 2 +- .../Realtime/Types/SessionBegins.cs | 6 + .../Realtime/Types/SessionInformation.cs | 6 + .../Realtime/Types/SessionTerminated.cs | 6 + src/AssemblyAI/Realtime/Types/Word.cs | 6 + .../Requests/GetSubtitlesParams.cs | 9 + .../Requests/ListTranscriptParams.cs | 9 + .../Transcripts/Requests/TranscriptParams.cs | 6 + .../Transcripts/Requests/WordSearchParams.cs | 9 + .../Transcripts/TranscriptsClient.cs | 192 ++++++++++++++---- .../Types/AudioIntelligenceModelStatus.cs | 2 +- .../Transcripts/Types/AutoHighlightResult.cs | 6 + .../Transcripts/Types/AutoHighlightsResult.cs | 6 + src/AssemblyAI/Transcripts/Types/Chapter.cs | 6 + .../Transcripts/Types/ContentSafetyLabel.cs | 6 + .../Types/ContentSafetyLabelResult.cs | 6 + src/AssemblyAI/Transcripts/Types/Entity.cs | 6 + .../Transcripts/Types/EntityType.cs | 2 +- .../Transcripts/Types/PageDetails.cs | 6 + .../Transcripts/Types/ParagraphsResponse.cs | 6 + src/AssemblyAI/Transcripts/Types/PiiPolicy.cs | 2 +- .../Types/RedactPiiAudioQuality.cs | 2 +- .../Types/RedactedAudioResponse.cs | 6 + .../Transcripts/Types/SentencesResponse.cs | 6 + src/AssemblyAI/Transcripts/Types/Sentiment.cs | 2 +- .../Types/SentimentAnalysisResult.cs | 6 + .../Transcripts/Types/SeverityScoreSummary.cs | 6 + .../Transcripts/Types/SpeechModel.cs | 2 +- .../Transcripts/Types/SubstitutionPolicy.cs | 2 +- .../Transcripts/Types/SubtitleFormat.cs | 2 +- .../Transcripts/Types/SummaryModel.cs | 2 +- .../Transcripts/Types/SummaryType.cs | 2 +- src/AssemblyAI/Transcripts/Types/Timestamp.cs | 6 + .../Transcripts/Types/TopicDetectionResult.cs | 6 + .../Types/TopicDetectionResultLabelsItem.cs | 6 + .../Transcripts/Types/Transcript.cs | 6 + .../Transcripts/Types/TranscriptBoostParam.cs | 2 +- .../Types/TranscriptCustomSpelling.cs | 6 + .../Types/TranscriptLanguageCode.cs | 2 +- .../Transcripts/Types/TranscriptList.cs | 6 + .../Transcripts/Types/TranscriptListItem.cs | 6 + .../Types/TranscriptOptionalParams.cs | 6 + .../Transcripts/Types/TranscriptParagraph.cs | 6 + .../Types/TranscriptReadyNotification.cs | 6 + .../Types/TranscriptReadyStatus.cs | 2 +- .../Transcripts/Types/TranscriptSentence.cs | 6 + .../Transcripts/Types/TranscriptStatus.cs | 2 +- .../Transcripts/Types/TranscriptUtterance.cs | 6 + .../Transcripts/Types/TranscriptWord.cs | 6 + .../Transcripts/Types/WordSearchMatch.cs | 6 + .../Transcripts/Types/WordSearchResponse.cs | 6 + 90 files changed, 778 insertions(+), 127 deletions(-) create mode 100644 src/AssemblyAI/Core/Extensions.cs create mode 100644 src/AssemblyAI/Core/HeaderValue.cs create mode 100644 src/AssemblyAI/Core/Headers.cs create mode 100644 src/AssemblyAI/Realtime/Types/Realtime.cs diff --git a/src/AssemblyAI/Core/Constants.cs b/src/AssemblyAI/Core/Constants.cs index c14737a..2e9e8eb 100644 --- a/src/AssemblyAI/Core/Constants.cs +++ b/src/AssemblyAI/Core/Constants.cs @@ -3,4 +3,5 @@ namespace AssemblyAI.Core; internal static class Constants { public const string DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK"; + public const string DateFormat = "yyyy-MM-dd"; } diff --git a/src/AssemblyAI/Core/Extensions.cs b/src/AssemblyAI/Core/Extensions.cs new file mode 100644 index 0000000..a1c7fef --- /dev/null +++ b/src/AssemblyAI/Core/Extensions.cs @@ -0,0 +1,14 @@ +using System.Runtime.Serialization; + +namespace AssemblyAI.Core; + +internal static class Extensions +{ + public static string Stringify(this Enum value) + { + var field = value.GetType().GetField(value.ToString()); + var attribute = (EnumMemberAttribute) + Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)); + return attribute?.Value ?? value.ToString(); + } +} diff --git a/src/AssemblyAI/Core/HeaderValue.cs b/src/AssemblyAI/Core/HeaderValue.cs new file mode 100644 index 0000000..2b6b9ef --- /dev/null +++ b/src/AssemblyAI/Core/HeaderValue.cs @@ -0,0 +1,17 @@ +using OneOf; + +namespace AssemblyAI.Core; + +internal sealed class HeaderValue(OneOf> value) + : OneOfBase>(value) +{ + public static implicit operator HeaderValue(string value) + { + return new HeaderValue(value); + } + + public static implicit operator HeaderValue(Func value) + { + return new HeaderValue(value); + } +} diff --git a/src/AssemblyAI/Core/Headers.cs b/src/AssemblyAI/Core/Headers.cs new file mode 100644 index 0000000..40e5064 --- /dev/null +++ b/src/AssemblyAI/Core/Headers.cs @@ -0,0 +1,17 @@ +namespace AssemblyAI.Core; + +internal sealed class Headers : Dictionary +{ + public Headers() { } + + public Headers(Dictionary value) + { + foreach (var kvp in value) + { + this[kvp.Key] = new HeaderValue(kvp.Value); + } + } + + public Headers(IEnumerable> value) + : base(value.ToDictionary(e => e.Key, e => e.Value)) { } +} diff --git a/src/AssemblyAI/Core/Public/AssemblyAIException.cs b/src/AssemblyAI/Core/Public/AssemblyAIException.cs index c8aa8df..edc89e2 100644 --- a/src/AssemblyAI/Core/Public/AssemblyAIException.cs +++ b/src/AssemblyAI/Core/Public/AssemblyAIException.cs @@ -7,10 +7,5 @@ namespace AssemblyAI; /// /// Base exception class for all exceptions thrown by the SDK. /// -public class AssemblyAIException : Exception -{ - internal AssemblyAIException(string message, Exception? innerException = null) - : base(message, innerException) - { - } -} +public class AssemblyAIException(string message, Exception? innerException = null) + : Exception(message, innerException) { } diff --git a/src/AssemblyAI/Core/Public/ClientOptions.cs b/src/AssemblyAI/Core/Public/ClientOptions.cs index 35a74e4..eb8b087 100644 --- a/src/AssemblyAI/Core/Public/ClientOptions.cs +++ b/src/AssemblyAI/Core/Public/ClientOptions.cs @@ -1,39 +1,35 @@ +using System; using System.Net.Http; -// ReSharper disable PartialTypeWithSinglePart -// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global -// ReSharper disable CheckNamespace +using AssemblyAI.Core; + +#nullable enable namespace AssemblyAI; public partial class ClientOptions { - /// - /// The AssemblyAI API key - /// - public required string ApiKey { get; set; } - /// /// The Base URL for the API. /// - public string BaseUrl { get; set; } = AssemblyAIClientEnvironment.Default; + public string BaseUrl { get; init; } = AssemblyAIClientEnvironment.Default; /// - /// The AssemblyAI user agent + /// The http client used to make requests. /// - public UserAgent UserAgent { get; set; } = new(); + public HttpClient HttpClient { get; init; } = new HttpClient(); /// /// The http client used to make requests. /// - public HttpClient? HttpClient { get; set; } + public int MaxRetries { get; init; } = 2; /// - /// The http client used to make requests. + /// The timeout for the request. /// - public int MaxRetries { get; set; } = 2; + public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(30); /// - /// The timeout for the request. + /// The http headers sent with the request. /// - public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(30); + internal Headers Headers { get; init; } = new(); } diff --git a/src/AssemblyAI/Core/Public/RequestOptions.cs b/src/AssemblyAI/Core/Public/RequestOptions.cs index 8ee511e..688540f 100644 --- a/src/AssemblyAI/Core/Public/RequestOptions.cs +++ b/src/AssemblyAI/Core/Public/RequestOptions.cs @@ -1,5 +1,6 @@ using System; using System.Net.Http; +using AssemblyAI.Core; #nullable enable @@ -26,4 +27,9 @@ public partial class RequestOptions /// The timeout for the request. /// public TimeSpan? Timeout { get; init; } + + /// + /// The http headers sent with the request. + /// + internal Headers Headers { get; init; } = new(); } diff --git a/src/AssemblyAI/Core/RawClient.cs b/src/AssemblyAI/Core/RawClient.cs index e7a51a2..82444ad 100644 --- a/src/AssemblyAI/Core/RawClient.cs +++ b/src/AssemblyAI/Core/RawClient.cs @@ -1,5 +1,6 @@ using System.Net.Http; using System.Text; +using System.Threading; namespace AssemblyAI.Core; @@ -8,23 +9,17 @@ namespace AssemblyAI.Core; /// /// Utility class for making raw HTTP requests to the API. /// -internal class RawClient( - Dictionary headers, - Dictionary> headerSuppliers, - ClientOptions clientOptions -) +internal class RawClient(ClientOptions clientOptions) { /// /// The http client used to make requests. /// public readonly ClientOptions Options = clientOptions; - /// - /// Global headers to be sent with every request. - /// - private readonly Dictionary _headers = headers; - - public async Task MakeRequestAsync(BaseApiRequest request) + public async Task MakeRequestAsync( + BaseApiRequest request, + CancellationToken cancellationToken = default + ) { var url = BuildUrl(request); var httpRequest = new HttpRequestMessage(request.Method, url); @@ -32,21 +27,10 @@ public async Task MakeRequestAsync(BaseApiRequest request) { request.Headers.Add("Content-Type", request.ContentType); } - // Add global headers to the request - foreach (var header in _headers) - { - httpRequest.Headers.Add(header.Key, header.Value); - } - // Add global headers to the request from supplier - foreach (var header in headerSuppliers) - { - httpRequest.Headers.Add(header.Key, header.Value.Invoke()); - } - // Add request headers to the request - foreach (var header in request.Headers) - { - httpRequest.Headers.Add(header.Key, header.Value); - } + SetHeaders(httpRequest, Options.Headers); + SetHeaders(httpRequest, request.Headers); + SetHeaders(httpRequest, request.Options?.Headers ?? new()); + // Add the request body to the request if (request is JsonApiRequest jsonRequest) { @@ -65,7 +49,7 @@ public async Task MakeRequestAsync(BaseApiRequest request) } // Send the request var httpClient = request.Options?.HttpClient ?? Options.HttpClient; - var response = await httpClient.SendAsync(httpRequest); + var response = await httpClient.SendAsync(httpRequest, cancellationToken); return new ApiResponse { StatusCode = (int)response.StatusCode, Raw = response }; } @@ -81,7 +65,7 @@ public record BaseApiRequest public Dictionary Query { get; init; } = new(); - public Dictionary Headers { get; init; } = new(); + public Headers Headers { get; init; } = new(); public RequestOptions? Options { get; init; } } @@ -112,6 +96,18 @@ public record ApiResponse public required HttpResponseMessage Raw { get; init; } } + private void SetHeaders(HttpRequestMessage httpRequest, Headers headers) + { + foreach (var header in headers) + { + var value = header.Value?.Match(str => str, func => func.Invoke()); + if (value != null) + { + httpRequest.Headers.TryAddWithoutValidation(header.Key, value); + } + } + } + private string BuildUrl(BaseApiRequest request) { var baseUrl = request.Options?.BaseUrl ?? request.BaseUrl; diff --git a/src/AssemblyAI/Files/FilesClient.cs b/src/AssemblyAI/Files/FilesClient.cs index 1923d9c..91ae90b 100644 --- a/src/AssemblyAI/Files/FilesClient.cs +++ b/src/AssemblyAI/Files/FilesClient.cs @@ -1,5 +1,6 @@ using System.Net.Http; using System.Text.Json; +using System.Threading; using AssemblyAI; using AssemblyAI.Core; @@ -19,7 +20,11 @@ internal FilesClient(RawClient client) /// /// Upload a media file to AssemblyAI's servers. /// - public async Task UploadAsync(Stream request, RequestOptions? options = null) + public async Task UploadAsync( + Stream request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.StreamApiRequest @@ -28,8 +33,9 @@ public async Task UploadAsync(Stream request, RequestOptions? opti Method = HttpMethod.Post, Path = "v2/upload", Body = request, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) diff --git a/src/AssemblyAI/Files/Types/UploadedFile.cs b/src/AssemblyAI/Files/Types/UploadedFile.cs index ba0260e..6f95f3d 100644 --- a/src/AssemblyAI/Files/Types/UploadedFile.cs +++ b/src/AssemblyAI/Files/Types/UploadedFile.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -11,4 +12,9 @@ public record UploadedFile /// [JsonPropertyName("upload_url")] public required string UploadUrl { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/LemurClient.cs b/src/AssemblyAI/Lemur/LemurClient.cs index 440a198..31596e8 100644 --- a/src/AssemblyAI/Lemur/LemurClient.cs +++ b/src/AssemblyAI/Lemur/LemurClient.cs @@ -1,5 +1,6 @@ using System.Net.Http; using System.Text.Json; +using System.Threading; using AssemblyAI; using AssemblyAI.Core; using OneOf; @@ -20,9 +21,25 @@ internal LemurClient(RawClient client) /// /// Use the LeMUR task endpoint to input your own LLM prompt. /// + /// + /// + /// await client.Lemur.TaskAsync( + /// new LemurTaskParams + /// { + /// TranscriptIds = new List() { "64nygnr62k-405c-4ae8-8a6b-d90b40ff3cce" }, + /// Context = "This is an interview about wildfires.", + /// FinalModel = LemurModel.Default, + /// MaxOutputSize = 3000, + /// Temperature = 0f, + /// Prompt = "List all the locations affected by wildfires.", + /// } + /// ); + /// + /// public async Task TaskAsync( LemurTaskParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -32,8 +49,9 @@ public async Task TaskAsync( Method = HttpMethod.Post, Path = "lemur/v3/generate/task", Body = request, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -59,9 +77,24 @@ public async Task TaskAsync( /// Custom Summary allows you to distill a piece of audio into a few impactful sentences. /// You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language. /// + /// + /// + /// await client.Lemur.SummaryAsync( + /// new LemurSummaryParams + /// { + /// TranscriptIds = new List() { "47b95ba5-8889-44d8-bc80-5de38306e582" }, + /// Context = "This is an interview about wildfires.", + /// FinalModel = LemurModel.Default, + /// MaxOutputSize = 3000, + /// Temperature = 0f, + /// } + /// ); + /// + /// public async Task SummaryAsync( LemurSummaryParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -71,8 +104,9 @@ public async Task SummaryAsync( Method = HttpMethod.Post, Path = "lemur/v3/generate/summary", Body = request, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -98,9 +132,38 @@ public async Task SummaryAsync( /// Question & Answer allows you to ask free-form questions about a single transcript or a group of transcripts. /// The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered. /// + /// + /// + /// await client.Lemur.QuestionAnswerAsync( + /// new LemurQuestionAnswerParams + /// { + /// TranscriptIds = new List() { "64nygnr62k-405c-4ae8-8a6b-d90b40ff3cce" }, + /// Context = "This is an interview about wildfires.", + /// FinalModel = LemurModel.Default, + /// MaxOutputSize = 3000, + /// Temperature = 0f, + /// Questions = new List() + /// { + /// new LemurQuestion + /// { + /// Question = "Where are there wildfires?", + /// AnswerFormat = "List of countries in ISO 3166-1 alpha-2 format", + /// AnswerOptions = new List() { "US", "CA" }, + /// }, + /// new LemurQuestion + /// { + /// Question = "Is global warming affecting wildfires?", + /// AnswerOptions = new List() { "yes", "no" }, + /// }, + /// }, + /// } + /// ); + /// + /// public async Task QuestionAnswerAsync( LemurQuestionAnswerParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -110,8 +173,9 @@ public async Task QuestionAnswerAsync( Method = HttpMethod.Post, Path = "lemur/v3/generate/question-answer", Body = request, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -136,9 +200,25 @@ public async Task QuestionAnswerAsync( /// /// Use LeMUR to generate a list of action items from a transcript /// + /// + /// + /// await client.Lemur.ActionItemsAsync( + /// new LemurActionItemsParams + /// { + /// TranscriptIds = new List() { "64nygnr62k-405c-4ae8-8a6b-d90b40ff3cce" }, + /// Context = "This is an interview about wildfires.", + /// FinalModel = LemurModel.Default, + /// MaxOutputSize = 3000, + /// Temperature = 0f, + /// AnswerFormat = "Bullet Points", + /// } + /// ); + /// + /// public async Task ActionItemsAsync( LemurActionItemsParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -148,8 +228,9 @@ public async Task ActionItemsAsync( Method = HttpMethod.Post, Path = "lemur/v3/generate/action-items", Body = request, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -174,9 +255,15 @@ public async Task ActionItemsAsync( /// /// Retrieve a LeMUR response that was previously generated. /// + /// + /// + /// await client.Lemur.GetResponseAsync("request_id"); + /// + /// public async Task> GetResponseAsync( string requestId, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -185,8 +272,9 @@ public async Task> GetRe BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = $"lemur/v3/{requestId}", - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -214,9 +302,15 @@ public async Task> GetRe /// Delete the data for a previously submitted LeMUR request. /// The LLM response data, as well as any context provided in the original request will be removed. /// + /// + /// + /// await client.Lemur.PurgeRequestDataAsync("request_id"); + /// + /// public async Task PurgeRequestDataAsync( string requestId, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -225,8 +319,9 @@ public async Task PurgeRequestDataAsync( BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, Path = $"lemur/v3/{requestId}", - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) diff --git a/src/AssemblyAI/Lemur/Requests/LemurActionItemsParams.cs b/src/AssemblyAI/Lemur/Requests/LemurActionItemsParams.cs index 3db192d..b2a08a1 100644 --- a/src/AssemblyAI/Lemur/Requests/LemurActionItemsParams.cs +++ b/src/AssemblyAI/Lemur/Requests/LemurActionItemsParams.cs @@ -56,4 +56,9 @@ public record LemurActionItemsParams /// [JsonPropertyName("temperature")] public float? Temperature { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Requests/LemurQuestionAnswerParams.cs b/src/AssemblyAI/Lemur/Requests/LemurQuestionAnswerParams.cs index 504df9d..dbdf8ef 100644 --- a/src/AssemblyAI/Lemur/Requests/LemurQuestionAnswerParams.cs +++ b/src/AssemblyAI/Lemur/Requests/LemurQuestionAnswerParams.cs @@ -54,4 +54,9 @@ public record LemurQuestionAnswerParams /// [JsonPropertyName("temperature")] public float? Temperature { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Requests/LemurSummaryParams.cs b/src/AssemblyAI/Lemur/Requests/LemurSummaryParams.cs index d12985a..1c946e4 100644 --- a/src/AssemblyAI/Lemur/Requests/LemurSummaryParams.cs +++ b/src/AssemblyAI/Lemur/Requests/LemurSummaryParams.cs @@ -55,4 +55,9 @@ public record LemurSummaryParams /// [JsonPropertyName("temperature")] public float? Temperature { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Requests/LemurTaskParams.cs b/src/AssemblyAI/Lemur/Requests/LemurTaskParams.cs index 950ea7c..bc38010 100644 --- a/src/AssemblyAI/Lemur/Requests/LemurTaskParams.cs +++ b/src/AssemblyAI/Lemur/Requests/LemurTaskParams.cs @@ -54,4 +54,9 @@ public record LemurTaskParams /// [JsonPropertyName("temperature")] public float? Temperature { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurActionItemsResponse.cs b/src/AssemblyAI/Lemur/Types/LemurActionItemsResponse.cs index 7df3642..4d3b6bb 100644 --- a/src/AssemblyAI/Lemur/Types/LemurActionItemsResponse.cs +++ b/src/AssemblyAI/Lemur/Types/LemurActionItemsResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record LemurActionItemsResponse /// [JsonPropertyName("usage")] public required LemurUsage Usage { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurBaseParams.cs b/src/AssemblyAI/Lemur/Types/LemurBaseParams.cs index 9a89088..d757dd1 100644 --- a/src/AssemblyAI/Lemur/Types/LemurBaseParams.cs +++ b/src/AssemblyAI/Lemur/Types/LemurBaseParams.cs @@ -48,4 +48,9 @@ public record LemurBaseParams /// [JsonPropertyName("temperature")] public float? Temperature { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurBaseResponse.cs b/src/AssemblyAI/Lemur/Types/LemurBaseResponse.cs index 22f91fd..ae8479f 100644 --- a/src/AssemblyAI/Lemur/Types/LemurBaseResponse.cs +++ b/src/AssemblyAI/Lemur/Types/LemurBaseResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record LemurBaseResponse /// [JsonPropertyName("usage")] public required LemurUsage Usage { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurModel.cs b/src/AssemblyAI/Lemur/Types/LemurModel.cs index 215a779..55b11af 100644 --- a/src/AssemblyAI/Lemur/Types/LemurModel.cs +++ b/src/AssemblyAI/Lemur/Types/LemurModel.cs @@ -37,5 +37,5 @@ public enum LemurModel Basic, [EnumMember(Value = "assemblyai/mistral-7b")] - AssemblyaiMistral7b + AssemblyaiMistral7b, } diff --git a/src/AssemblyAI/Lemur/Types/LemurQuestion.cs b/src/AssemblyAI/Lemur/Types/LemurQuestion.cs index c86bbc3..59ac5fc 100644 --- a/src/AssemblyAI/Lemur/Types/LemurQuestion.cs +++ b/src/AssemblyAI/Lemur/Types/LemurQuestion.cs @@ -32,4 +32,9 @@ public record LemurQuestion /// [JsonPropertyName("answer_options")] public IEnumerable? AnswerOptions { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurQuestionAnswer.cs b/src/AssemblyAI/Lemur/Types/LemurQuestionAnswer.cs index 2588176..c46c657 100644 --- a/src/AssemblyAI/Lemur/Types/LemurQuestionAnswer.cs +++ b/src/AssemblyAI/Lemur/Types/LemurQuestionAnswer.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record LemurQuestionAnswer /// [JsonPropertyName("answer")] public required string Answer { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurQuestionAnswerResponse.cs b/src/AssemblyAI/Lemur/Types/LemurQuestionAnswerResponse.cs index a73d001..f8a14dc 100644 --- a/src/AssemblyAI/Lemur/Types/LemurQuestionAnswerResponse.cs +++ b/src/AssemblyAI/Lemur/Types/LemurQuestionAnswerResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -24,4 +25,9 @@ public record LemurQuestionAnswerResponse /// [JsonPropertyName("usage")] public required LemurUsage Usage { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurStringResponse.cs b/src/AssemblyAI/Lemur/Types/LemurStringResponse.cs index add46cd..eba30db 100644 --- a/src/AssemblyAI/Lemur/Types/LemurStringResponse.cs +++ b/src/AssemblyAI/Lemur/Types/LemurStringResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record LemurStringResponse /// [JsonPropertyName("usage")] public required LemurUsage Usage { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurSummaryResponse.cs b/src/AssemblyAI/Lemur/Types/LemurSummaryResponse.cs index 5588e61..b2aeb47 100644 --- a/src/AssemblyAI/Lemur/Types/LemurSummaryResponse.cs +++ b/src/AssemblyAI/Lemur/Types/LemurSummaryResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record LemurSummaryResponse /// [JsonPropertyName("usage")] public required LemurUsage Usage { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurTaskResponse.cs b/src/AssemblyAI/Lemur/Types/LemurTaskResponse.cs index 56ce009..5089749 100644 --- a/src/AssemblyAI/Lemur/Types/LemurTaskResponse.cs +++ b/src/AssemblyAI/Lemur/Types/LemurTaskResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record LemurTaskResponse /// [JsonPropertyName("usage")] public required LemurUsage Usage { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/LemurUsage.cs b/src/AssemblyAI/Lemur/Types/LemurUsage.cs index c5ea010..858633f 100644 --- a/src/AssemblyAI/Lemur/Types/LemurUsage.cs +++ b/src/AssemblyAI/Lemur/Types/LemurUsage.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record LemurUsage /// [JsonPropertyName("output_tokens")] public required int OutputTokens { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Lemur/Types/PurgeLemurRequestDataResponse.cs b/src/AssemblyAI/Lemur/Types/PurgeLemurRequestDataResponse.cs index 3cc18ff..a953296 100644 --- a/src/AssemblyAI/Lemur/Types/PurgeLemurRequestDataResponse.cs +++ b/src/AssemblyAI/Lemur/Types/PurgeLemurRequestDataResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record PurgeLemurRequestDataResponse /// [JsonPropertyName("deleted")] public required bool Deleted { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/RealtimeClient.cs b/src/AssemblyAI/Realtime/RealtimeClient.cs index 5f148e2..d06e881 100644 --- a/src/AssemblyAI/Realtime/RealtimeClient.cs +++ b/src/AssemblyAI/Realtime/RealtimeClient.cs @@ -1,5 +1,6 @@ using System.Net.Http; using System.Text.Json; +using System.Threading; using AssemblyAI; using AssemblyAI.Core; @@ -19,9 +20,17 @@ internal RealtimeClient(RawClient client) /// /// Create a temporary authentication token for Streaming Speech-to-Text /// + /// + /// + /// await client.Realtime.CreateTemporaryTokenAsync( + /// new CreateRealtimeTemporaryTokenParams { ExpiresIn = 480 } + /// ); + /// + /// public async Task CreateTemporaryTokenAsync( CreateRealtimeTemporaryTokenParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -31,8 +40,9 @@ public async Task CreateTemporaryTokenAsync( Method = HttpMethod.Post, Path = "v2/realtime/token", Body = request, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) diff --git a/src/AssemblyAI/Realtime/Requests/CreateRealtimeTemporaryTokenParams.cs b/src/AssemblyAI/Realtime/Requests/CreateRealtimeTemporaryTokenParams.cs index dff15a0..c724e87 100644 --- a/src/AssemblyAI/Realtime/Requests/CreateRealtimeTemporaryTokenParams.cs +++ b/src/AssemblyAI/Realtime/Requests/CreateRealtimeTemporaryTokenParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -11,4 +12,9 @@ public record CreateRealtimeTemporaryTokenParams /// [JsonPropertyName("expires_in")] public required int ExpiresIn { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/AudioEncoding.cs b/src/AssemblyAI/Realtime/Types/AudioEncoding.cs index e988e7f..e15f895 100644 --- a/src/AssemblyAI/Realtime/Types/AudioEncoding.cs +++ b/src/AssemblyAI/Realtime/Types/AudioEncoding.cs @@ -13,5 +13,5 @@ public enum AudioEncoding PcmS16le, [EnumMember(Value = "pcm_mulaw")] - PcmMulaw + PcmMulaw, } diff --git a/src/AssemblyAI/Realtime/Types/ConfigureEndUtteranceSilenceThreshold.cs b/src/AssemblyAI/Realtime/Types/ConfigureEndUtteranceSilenceThreshold.cs index fba9ffe..536984e 100644 --- a/src/AssemblyAI/Realtime/Types/ConfigureEndUtteranceSilenceThreshold.cs +++ b/src/AssemblyAI/Realtime/Types/ConfigureEndUtteranceSilenceThreshold.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -11,4 +12,9 @@ public record ConfigureEndUtteranceSilenceThreshold /// [JsonPropertyName("end_utterance_silence_threshold")] public required int EndUtteranceSilenceThreshold { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/FinalTranscript.cs b/src/AssemblyAI/Realtime/Types/FinalTranscript.cs index fccb08b..4816900 100644 --- a/src/AssemblyAI/Realtime/Types/FinalTranscript.cs +++ b/src/AssemblyAI/Realtime/Types/FinalTranscript.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -60,4 +61,9 @@ public record FinalTranscript /// [JsonPropertyName("created")] public required DateTime Created { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/MessageType.cs b/src/AssemblyAI/Realtime/Types/MessageType.cs index a125ca9..e315ba9 100644 --- a/src/AssemblyAI/Realtime/Types/MessageType.cs +++ b/src/AssemblyAI/Realtime/Types/MessageType.cs @@ -22,5 +22,5 @@ public enum MessageType SessionInformation, [EnumMember(Value = "SessionTerminated")] - SessionTerminated + SessionTerminated, } diff --git a/src/AssemblyAI/Realtime/Types/PartialTranscript.cs b/src/AssemblyAI/Realtime/Types/PartialTranscript.cs index f607c93..e256c2e 100644 --- a/src/AssemblyAI/Realtime/Types/PartialTranscript.cs +++ b/src/AssemblyAI/Realtime/Types/PartialTranscript.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -48,4 +49,9 @@ public record PartialTranscript /// [JsonPropertyName("created")] public required DateTime Created { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/Realtime.cs b/src/AssemblyAI/Realtime/Types/Realtime.cs new file mode 100644 index 0000000..a36c002 --- /dev/null +++ b/src/AssemblyAI/Realtime/Types/Realtime.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using AssemblyAI.Core; + +#nullable enable + +namespace AssemblyAI.Realtime; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum Realtime +{ + [EnumMember(Value = "pcm_s16le")] + PcmS16le, + + [EnumMember(Value = "pcm_mulaw")] + PcmMulaw, +} diff --git a/src/AssemblyAI/Realtime/Types/RealtimeBaseMessage.cs b/src/AssemblyAI/Realtime/Types/RealtimeBaseMessage.cs index 6baa835..1496eb3 100644 --- a/src/AssemblyAI/Realtime/Types/RealtimeBaseMessage.cs +++ b/src/AssemblyAI/Realtime/Types/RealtimeBaseMessage.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -11,4 +12,9 @@ public record RealtimeBaseMessage /// [JsonPropertyName("message_type")] public required MessageType MessageType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/RealtimeBaseTranscript.cs b/src/AssemblyAI/Realtime/Types/RealtimeBaseTranscript.cs index 0a86bb3..4596bc7 100644 --- a/src/AssemblyAI/Realtime/Types/RealtimeBaseTranscript.cs +++ b/src/AssemblyAI/Realtime/Types/RealtimeBaseTranscript.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -42,4 +43,9 @@ public record RealtimeBaseTranscript /// [JsonPropertyName("created")] public required DateTime Created { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/RealtimeError.cs b/src/AssemblyAI/Realtime/Types/RealtimeError.cs index e6b2c72..a10bf55 100644 --- a/src/AssemblyAI/Realtime/Types/RealtimeError.cs +++ b/src/AssemblyAI/Realtime/Types/RealtimeError.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -8,4 +9,9 @@ public record RealtimeError { [JsonPropertyName("error")] public required string Error { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/RealtimeTemporaryTokenResponse.cs b/src/AssemblyAI/Realtime/Types/RealtimeTemporaryTokenResponse.cs index dc7f751..3aa4535 100644 --- a/src/AssemblyAI/Realtime/Types/RealtimeTemporaryTokenResponse.cs +++ b/src/AssemblyAI/Realtime/Types/RealtimeTemporaryTokenResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -11,4 +12,9 @@ public record RealtimeTemporaryTokenResponse /// [JsonPropertyName("token")] public required string Token { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/RealtimeTranscriptType.cs b/src/AssemblyAI/Realtime/Types/RealtimeTranscriptType.cs index 34e1b70..67b92f8 100644 --- a/src/AssemblyAI/Realtime/Types/RealtimeTranscriptType.cs +++ b/src/AssemblyAI/Realtime/Types/RealtimeTranscriptType.cs @@ -13,5 +13,5 @@ public enum RealtimeTranscriptType PartialTranscript, [EnumMember(Value = "FinalTranscript")] - FinalTranscript + FinalTranscript, } diff --git a/src/AssemblyAI/Realtime/Types/SessionBegins.cs b/src/AssemblyAI/Realtime/Types/SessionBegins.cs index 6f11bfb..6c3ed1a 100644 --- a/src/AssemblyAI/Realtime/Types/SessionBegins.cs +++ b/src/AssemblyAI/Realtime/Types/SessionBegins.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record SessionBegins /// [JsonPropertyName("expires_at")] public required DateTime ExpiresAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/SessionInformation.cs b/src/AssemblyAI/Realtime/Types/SessionInformation.cs index 30f279d..53ba303 100644 --- a/src/AssemblyAI/Realtime/Types/SessionInformation.cs +++ b/src/AssemblyAI/Realtime/Types/SessionInformation.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record SessionInformation /// [JsonPropertyName("audio_duration_seconds")] public required float AudioDurationSeconds { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/SessionTerminated.cs b/src/AssemblyAI/Realtime/Types/SessionTerminated.cs index cf4d630..f1971a2 100644 --- a/src/AssemblyAI/Realtime/Types/SessionTerminated.cs +++ b/src/AssemblyAI/Realtime/Types/SessionTerminated.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -11,4 +12,9 @@ public record SessionTerminated /// [JsonPropertyName("message_type")] public required string MessageType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Realtime/Types/Word.cs b/src/AssemblyAI/Realtime/Types/Word.cs index bc8fa03..b72fbeb 100644 --- a/src/AssemblyAI/Realtime/Types/Word.cs +++ b/src/AssemblyAI/Realtime/Types/Word.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -29,4 +30,9 @@ public record Word /// [JsonPropertyName("text")] public required string Text { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Requests/GetSubtitlesParams.cs b/src/AssemblyAI/Transcripts/Requests/GetSubtitlesParams.cs index a49da48..f18c32b 100644 --- a/src/AssemblyAI/Transcripts/Requests/GetSubtitlesParams.cs +++ b/src/AssemblyAI/Transcripts/Requests/GetSubtitlesParams.cs @@ -1,3 +1,7 @@ +using AssemblyAI.Core; + +#nullable enable + namespace AssemblyAI.Transcripts; public record GetSubtitlesParams @@ -6,4 +10,9 @@ public record GetSubtitlesParams /// The maximum number of characters per caption /// public int? CharsPerCaption { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Requests/ListTranscriptParams.cs b/src/AssemblyAI/Transcripts/Requests/ListTranscriptParams.cs index 969a45f..b6537b9 100644 --- a/src/AssemblyAI/Transcripts/Requests/ListTranscriptParams.cs +++ b/src/AssemblyAI/Transcripts/Requests/ListTranscriptParams.cs @@ -1,3 +1,7 @@ +using AssemblyAI.Core; + +#nullable enable + namespace AssemblyAI.Transcripts; public record ListTranscriptParams @@ -31,4 +35,9 @@ public record ListTranscriptParams /// Only get throttled transcripts, overrides the status filter /// public bool? ThrottledOnly { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Requests/TranscriptParams.cs b/src/AssemblyAI/Transcripts/Requests/TranscriptParams.cs index 9b5c096..69e8590 100644 --- a/src/AssemblyAI/Transcripts/Requests/TranscriptParams.cs +++ b/src/AssemblyAI/Transcripts/Requests/TranscriptParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -227,4 +228,9 @@ public record TranscriptParams /// [JsonPropertyName("topics")] public IEnumerable? Topics { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Requests/WordSearchParams.cs b/src/AssemblyAI/Transcripts/Requests/WordSearchParams.cs index 7f0496c..45f095b 100644 --- a/src/AssemblyAI/Transcripts/Requests/WordSearchParams.cs +++ b/src/AssemblyAI/Transcripts/Requests/WordSearchParams.cs @@ -1,3 +1,7 @@ +using AssemblyAI.Core; + +#nullable enable + namespace AssemblyAI.Transcripts; public record WordSearchParams @@ -6,4 +10,9 @@ public record WordSearchParams /// Keywords to search for /// public IEnumerable Words { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/TranscriptsClient.cs b/src/AssemblyAI/Transcripts/TranscriptsClient.cs index 1eb4382..61a1773 100644 --- a/src/AssemblyAI/Transcripts/TranscriptsClient.cs +++ b/src/AssemblyAI/Transcripts/TranscriptsClient.cs @@ -1,5 +1,6 @@ using System.Net.Http; using System.Text.Json; +using System.Threading; using AssemblyAI; using AssemblyAI.Core; @@ -20,19 +21,25 @@ internal TranscriptsClient(RawClient client) /// Retrieve a list of transcripts you created. /// Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts. /// + /// + /// + /// await client.Transcripts.ListAsync(new ListTranscriptParams()); + /// + /// public async Task ListAsync( ListTranscriptParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); } if (request.Status != null) { - _query["status"] = JsonSerializer.Serialize(request.Status.Value); + _query["status"] = request.Status.Value.Stringify(); } if (request.CreatedOn != null) { @@ -57,8 +64,9 @@ public async Task ListAsync( Method = HttpMethod.Get, Path = "v2/transcript", Query = _query, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -83,9 +91,66 @@ public async Task ListAsync( /// /// Create a transcript from a media file that is accessible via a URL. /// + /// + /// + /// await client.Transcripts.SubmitAsync( + /// new TranscriptParams + /// { + /// LanguageCode = TranscriptLanguageCode.EnUs, + /// LanguageDetection = false, + /// Punctuate = true, + /// FormatText = true, + /// Disfluencies = false, + /// DualChannel = true, + /// WebhookUrl = "https://your-webhook-url/path", + /// WebhookAuthHeaderName = "webhook-secret", + /// WebhookAuthHeaderValue = "webhook-secret-value", + /// AutoHighlights = true, + /// AudioStartFrom = 10, + /// AudioEndAt = 280, + /// WordBoost = new List() { "aws", "azure", "google cloud" }, + /// BoostParam = TranscriptBoostParam.High, + /// FilterProfanity = true, + /// RedactPii = true, + /// RedactPiiAudio = true, + /// RedactPiiAudioQuality = RedactPiiAudioQuality.Mp3, + /// RedactPiiPolicies = new List() + /// { + /// PiiPolicy.UsSocialSecurityNumber, + /// PiiPolicy.CreditCardNumber, + /// }, + /// RedactPiiSub = SubstitutionPolicy.Hash, + /// SpeakerLabels = true, + /// SpeakersExpected = 2, + /// ContentSafety = true, + /// IabCategories = true, + /// CustomSpelling = new List() + /// { + /// new TranscriptCustomSpelling + /// { + /// From = new List() { "dicarlo" }, + /// To = "Decarlo", + /// }, + /// }, + /// SentimentAnalysis = true, + /// AutoChapters = true, + /// EntityDetection = true, + /// SpeechThreshold = 0.5f, + /// Summarization = true, + /// SummaryModel = SummaryModel.Informative, + /// SummaryType = SummaryType.Bullets, + /// CustomTopics = true, + /// Topics = new List() { "topics" }, + /// AudioUrl = + /// "https://github.com/AssemblyAI-Examples/audio-examples/raw/main/20230607_me_canadian_wildfires.mp3", + /// } + /// ); + /// + /// public async Task SubmitAsync( TranscriptParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -95,8 +160,9 @@ public async Task SubmitAsync( Method = HttpMethod.Post, Path = "v2/transcript", Body = request, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -121,7 +187,16 @@ public async Task SubmitAsync( /// /// Get the transcript resource. The transcript is ready when the "status" is "completed". /// - public async Task GetAsync(string transcriptId, RequestOptions? options = null) + /// + /// + /// await client.Transcripts.GetAsync("transcript_id"); + /// + /// + public async Task GetAsync( + string transcriptId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest @@ -129,8 +204,9 @@ public async Task GetAsync(string transcriptId, RequestOptions? opti BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = $"v2/transcript/{transcriptId}", - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -155,7 +231,16 @@ public async Task GetAsync(string transcriptId, RequestOptions? opti /// /// Remove the data from the transcript and mark it as deleted. /// - public async Task DeleteAsync(string transcriptId, RequestOptions? options = null) + /// + /// + /// await client.Transcripts.DeleteAsync("{transcript_id}"); + /// + /// + public async Task DeleteAsync( + string transcriptId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest @@ -163,8 +248,9 @@ public async Task DeleteAsync(string transcriptId, RequestOptions? o BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, Path = $"v2/transcript/{transcriptId}", - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -189,28 +275,38 @@ public async Task DeleteAsync(string transcriptId, RequestOptions? o /// /// Export your transcript in SRT or VTT format to use with a video player for subtitles and closed captions. /// + /// + /// + /// await client.Transcripts.GetSubtitlesAsync( + /// "string", + /// SubtitleFormat.Srt, + /// new GetSubtitlesParams { CharsPerCaption = 1 } + /// ); + /// + /// public async Task GetSubtitlesAsync( string transcriptId, SubtitleFormat subtitleFormat, GetSubtitlesParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.CharsPerCaption != null) { _query["chars_per_caption"] = request.CharsPerCaption.ToString(); } - var formatSlug = subtitleFormat == SubtitleFormat.Srt ? "srt" : "vtt"; var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"v2/transcript/{transcriptId}/{formatSlug}", + Path = $"v2/transcript/{transcriptId}/{subtitleFormat}", Query = _query, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -227,9 +323,15 @@ public async Task GetSubtitlesAsync( /// /// Get the transcript split by sentences. The API will attempt to semantically segment the transcript into sentences to create more reader-friendly transcripts. /// + /// + /// + /// await client.Transcripts.GetSentencesAsync("transcript_id"); + /// + /// public async Task GetSentencesAsync( string transcriptId, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -238,8 +340,9 @@ public async Task GetSentencesAsync( BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = $"v2/transcript/{transcriptId}/sentences", - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -264,9 +367,15 @@ public async Task GetSentencesAsync( /// /// Get the transcript split by paragraphs. The API will attempt to semantically segment your transcript into paragraphs to create more reader-friendly transcripts. /// + /// + /// + /// await client.Transcripts.GetParagraphsAsync("transcript_id"); + /// + /// public async Task GetParagraphsAsync( string transcriptId, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -275,8 +384,9 @@ public async Task GetParagraphsAsync( BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = $"v2/transcript/{transcriptId}/paragraphs", - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -301,14 +411,20 @@ public async Task GetParagraphsAsync( /// /// Search through the transcript for keywords. You can search for individual words, numbers, or phrases containing up to five words or numbers. /// + /// + /// + /// await client.Transcripts.WordSearchAsync("string", new WordSearchParams { Words = ["string"] }); + /// + /// public async Task WordSearchAsync( string transcriptId, WordSearchParams request, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; - _query["words"] = string.Join(",", request.Words); + var _query = new Dictionary(); + _query["words"] = request.Words; var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { @@ -316,8 +432,9 @@ public async Task WordSearchAsync( Method = HttpMethod.Get, Path = $"v2/transcript/{transcriptId}/word-search", Query = _query, - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) @@ -342,9 +459,15 @@ public async Task WordSearchAsync( /// /// Retrieve the redacted audio object containing the status and URL to the redacted audio. /// + /// + /// + /// await client.Transcripts.GetRedactedAudioAsync("transcript_id"); + /// + /// public async Task GetRedactedAudioAsync( string transcriptId, - RequestOptions? options = null + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( @@ -353,8 +476,9 @@ public async Task GetRedactedAudioAsync( BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = $"v2/transcript/{transcriptId}/redacted-audio", - Options = options - } + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) diff --git a/src/AssemblyAI/Transcripts/Types/AudioIntelligenceModelStatus.cs b/src/AssemblyAI/Transcripts/Types/AudioIntelligenceModelStatus.cs index 47b1146..84b0259 100644 --- a/src/AssemblyAI/Transcripts/Types/AudioIntelligenceModelStatus.cs +++ b/src/AssemblyAI/Transcripts/Types/AudioIntelligenceModelStatus.cs @@ -13,5 +13,5 @@ public enum AudioIntelligenceModelStatus Success, [EnumMember(Value = "unavailable")] - Unavailable + Unavailable, } diff --git a/src/AssemblyAI/Transcripts/Types/AutoHighlightResult.cs b/src/AssemblyAI/Transcripts/Types/AutoHighlightResult.cs index c7e38bc..ac1cfe3 100644 --- a/src/AssemblyAI/Transcripts/Types/AutoHighlightResult.cs +++ b/src/AssemblyAI/Transcripts/Types/AutoHighlightResult.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -29,4 +30,9 @@ public record AutoHighlightResult /// [JsonPropertyName("timestamps")] public IEnumerable Timestamps { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/AutoHighlightsResult.cs b/src/AssemblyAI/Transcripts/Types/AutoHighlightsResult.cs index 3039a6e..9e5123d 100644 --- a/src/AssemblyAI/Transcripts/Types/AutoHighlightsResult.cs +++ b/src/AssemblyAI/Transcripts/Types/AutoHighlightsResult.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record AutoHighlightsResult /// [JsonPropertyName("results")] public IEnumerable Results { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/Chapter.cs b/src/AssemblyAI/Transcripts/Types/Chapter.cs index 7387833..5064631 100644 --- a/src/AssemblyAI/Transcripts/Types/Chapter.cs +++ b/src/AssemblyAI/Transcripts/Types/Chapter.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -35,4 +36,9 @@ public record Chapter /// [JsonPropertyName("end")] public required int End { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/ContentSafetyLabel.cs b/src/AssemblyAI/Transcripts/Types/ContentSafetyLabel.cs index e138f52..8aa0b8c 100644 --- a/src/AssemblyAI/Transcripts/Types/ContentSafetyLabel.cs +++ b/src/AssemblyAI/Transcripts/Types/ContentSafetyLabel.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record ContentSafetyLabel /// [JsonPropertyName("severity")] public required double Severity { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/ContentSafetyLabelResult.cs b/src/AssemblyAI/Transcripts/Types/ContentSafetyLabelResult.cs index 29a26a7..bb23f3f 100644 --- a/src/AssemblyAI/Transcripts/Types/ContentSafetyLabelResult.cs +++ b/src/AssemblyAI/Transcripts/Types/ContentSafetyLabelResult.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -35,4 +36,9 @@ public record ContentSafetyLabelResult /// [JsonPropertyName("timestamp")] public required Timestamp Timestamp { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/Entity.cs b/src/AssemblyAI/Transcripts/Types/Entity.cs index dc5ea11..8f867ee 100644 --- a/src/AssemblyAI/Transcripts/Types/Entity.cs +++ b/src/AssemblyAI/Transcripts/Types/Entity.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -29,4 +30,9 @@ public record Entity /// [JsonPropertyName("end")] public required int End { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/EntityType.cs b/src/AssemblyAI/Transcripts/Types/EntityType.cs index d4785eb..98f95bc 100644 --- a/src/AssemblyAI/Transcripts/Types/EntityType.cs +++ b/src/AssemblyAI/Transcripts/Types/EntityType.cs @@ -139,5 +139,5 @@ public enum EntityType VehicleId, [EnumMember(Value = "zodiac_sign")] - ZodiacSign + ZodiacSign, } diff --git a/src/AssemblyAI/Transcripts/Types/PageDetails.cs b/src/AssemblyAI/Transcripts/Types/PageDetails.cs index 9d33f30..129a510 100644 --- a/src/AssemblyAI/Transcripts/Types/PageDetails.cs +++ b/src/AssemblyAI/Transcripts/Types/PageDetails.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -35,4 +36,9 @@ public record PageDetails /// [JsonPropertyName("next_url")] public string? NextUrl { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/ParagraphsResponse.cs b/src/AssemblyAI/Transcripts/Types/ParagraphsResponse.cs index e63612d..dadf613 100644 --- a/src/AssemblyAI/Transcripts/Types/ParagraphsResponse.cs +++ b/src/AssemblyAI/Transcripts/Types/ParagraphsResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -18,4 +19,9 @@ public record ParagraphsResponse [JsonPropertyName("paragraphs")] public IEnumerable Paragraphs { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/PiiPolicy.cs b/src/AssemblyAI/Transcripts/Types/PiiPolicy.cs index 148375c..441d1f0 100644 --- a/src/AssemblyAI/Transcripts/Types/PiiPolicy.cs +++ b/src/AssemblyAI/Transcripts/Types/PiiPolicy.cs @@ -139,5 +139,5 @@ public enum PiiPolicy VehicleId, [EnumMember(Value = "zodiac_sign")] - ZodiacSign + ZodiacSign, } diff --git a/src/AssemblyAI/Transcripts/Types/RedactPiiAudioQuality.cs b/src/AssemblyAI/Transcripts/Types/RedactPiiAudioQuality.cs index e09266c..6b59661 100644 --- a/src/AssemblyAI/Transcripts/Types/RedactPiiAudioQuality.cs +++ b/src/AssemblyAI/Transcripts/Types/RedactPiiAudioQuality.cs @@ -13,5 +13,5 @@ public enum RedactPiiAudioQuality Mp3, [EnumMember(Value = "wav")] - Wav + Wav, } diff --git a/src/AssemblyAI/Transcripts/Types/RedactedAudioResponse.cs b/src/AssemblyAI/Transcripts/Types/RedactedAudioResponse.cs index bac1809..a510e33 100644 --- a/src/AssemblyAI/Transcripts/Types/RedactedAudioResponse.cs +++ b/src/AssemblyAI/Transcripts/Types/RedactedAudioResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record RedactedAudioResponse /// [JsonPropertyName("redacted_audio_url")] public required string RedactedAudioUrl { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/SentencesResponse.cs b/src/AssemblyAI/Transcripts/Types/SentencesResponse.cs index dfd3f4c..83a8ccf 100644 --- a/src/AssemblyAI/Transcripts/Types/SentencesResponse.cs +++ b/src/AssemblyAI/Transcripts/Types/SentencesResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record SentencesResponse [JsonPropertyName("sentences")] public IEnumerable Sentences { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/Sentiment.cs b/src/AssemblyAI/Transcripts/Types/Sentiment.cs index aeee4aa..9748841 100644 --- a/src/AssemblyAI/Transcripts/Types/Sentiment.cs +++ b/src/AssemblyAI/Transcripts/Types/Sentiment.cs @@ -16,5 +16,5 @@ public enum Sentiment Neutral, [EnumMember(Value = "NEGATIVE")] - Negative + Negative, } diff --git a/src/AssemblyAI/Transcripts/Types/SentimentAnalysisResult.cs b/src/AssemblyAI/Transcripts/Types/SentimentAnalysisResult.cs index faa3ad9..f11876d 100644 --- a/src/AssemblyAI/Transcripts/Types/SentimentAnalysisResult.cs +++ b/src/AssemblyAI/Transcripts/Types/SentimentAnalysisResult.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -41,4 +42,9 @@ public record SentimentAnalysisResult /// [JsonPropertyName("speaker")] public string? Speaker { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/SeverityScoreSummary.cs b/src/AssemblyAI/Transcripts/Types/SeverityScoreSummary.cs index c9d3209..ab44de1 100644 --- a/src/AssemblyAI/Transcripts/Types/SeverityScoreSummary.cs +++ b/src/AssemblyAI/Transcripts/Types/SeverityScoreSummary.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -14,4 +15,9 @@ public record SeverityScoreSummary [JsonPropertyName("high")] public required double High { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/SpeechModel.cs b/src/AssemblyAI/Transcripts/Types/SpeechModel.cs index c063a1c..ea981fd 100644 --- a/src/AssemblyAI/Transcripts/Types/SpeechModel.cs +++ b/src/AssemblyAI/Transcripts/Types/SpeechModel.cs @@ -13,5 +13,5 @@ public enum SpeechModel Best, [EnumMember(Value = "nano")] - Nano + Nano, } diff --git a/src/AssemblyAI/Transcripts/Types/SubstitutionPolicy.cs b/src/AssemblyAI/Transcripts/Types/SubstitutionPolicy.cs index 60a06be..b29eeb6 100644 --- a/src/AssemblyAI/Transcripts/Types/SubstitutionPolicy.cs +++ b/src/AssemblyAI/Transcripts/Types/SubstitutionPolicy.cs @@ -13,5 +13,5 @@ public enum SubstitutionPolicy EntityName, [EnumMember(Value = "hash")] - Hash + Hash, } diff --git a/src/AssemblyAI/Transcripts/Types/SubtitleFormat.cs b/src/AssemblyAI/Transcripts/Types/SubtitleFormat.cs index e164807..ebe6a8f 100644 --- a/src/AssemblyAI/Transcripts/Types/SubtitleFormat.cs +++ b/src/AssemblyAI/Transcripts/Types/SubtitleFormat.cs @@ -13,5 +13,5 @@ public enum SubtitleFormat Srt, [EnumMember(Value = "vtt")] - Vtt + Vtt, } diff --git a/src/AssemblyAI/Transcripts/Types/SummaryModel.cs b/src/AssemblyAI/Transcripts/Types/SummaryModel.cs index f230010..d935aa2 100644 --- a/src/AssemblyAI/Transcripts/Types/SummaryModel.cs +++ b/src/AssemblyAI/Transcripts/Types/SummaryModel.cs @@ -16,5 +16,5 @@ public enum SummaryModel Conversational, [EnumMember(Value = "catchy")] - Catchy + Catchy, } diff --git a/src/AssemblyAI/Transcripts/Types/SummaryType.cs b/src/AssemblyAI/Transcripts/Types/SummaryType.cs index b95e282..4145146 100644 --- a/src/AssemblyAI/Transcripts/Types/SummaryType.cs +++ b/src/AssemblyAI/Transcripts/Types/SummaryType.cs @@ -22,5 +22,5 @@ public enum SummaryType Headline, [EnumMember(Value = "paragraph")] - Paragraph + Paragraph, } diff --git a/src/AssemblyAI/Transcripts/Types/Timestamp.cs b/src/AssemblyAI/Transcripts/Types/Timestamp.cs index 48a8c7b..1e1ec82 100644 --- a/src/AssemblyAI/Transcripts/Types/Timestamp.cs +++ b/src/AssemblyAI/Transcripts/Types/Timestamp.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record Timestamp /// [JsonPropertyName("end")] public required int End { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TopicDetectionResult.cs b/src/AssemblyAI/Transcripts/Types/TopicDetectionResult.cs index ae6aac3..727b008 100644 --- a/src/AssemblyAI/Transcripts/Types/TopicDetectionResult.cs +++ b/src/AssemblyAI/Transcripts/Types/TopicDetectionResult.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record TopicDetectionResult [JsonPropertyName("timestamp")] public Timestamp? Timestamp { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TopicDetectionResultLabelsItem.cs b/src/AssemblyAI/Transcripts/Types/TopicDetectionResultLabelsItem.cs index 479eae1..b9cc515 100644 --- a/src/AssemblyAI/Transcripts/Types/TopicDetectionResultLabelsItem.cs +++ b/src/AssemblyAI/Transcripts/Types/TopicDetectionResultLabelsItem.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record TopicDetectionResultLabelsItem /// [JsonPropertyName("label")] public required string Label { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/Transcript.cs b/src/AssemblyAI/Transcripts/Types/Transcript.cs index 65c916c..7812614 100644 --- a/src/AssemblyAI/Transcripts/Types/Transcript.cs +++ b/src/AssemblyAI/Transcripts/Types/Transcript.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -352,4 +353,9 @@ public record Transcript /// [JsonPropertyName("acoustic_model")] public required string AcousticModel { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptBoostParam.cs b/src/AssemblyAI/Transcripts/Types/TranscriptBoostParam.cs index 6edfb41..6f1ca95 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptBoostParam.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptBoostParam.cs @@ -16,5 +16,5 @@ public enum TranscriptBoostParam Default, [EnumMember(Value = "high")] - High + High, } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptCustomSpelling.cs b/src/AssemblyAI/Transcripts/Types/TranscriptCustomSpelling.cs index 42603ec..dca962d 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptCustomSpelling.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptCustomSpelling.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record TranscriptCustomSpelling /// [JsonPropertyName("to")] public required string To { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptLanguageCode.cs b/src/AssemblyAI/Transcripts/Types/TranscriptLanguageCode.cs index 6623789..31f39d4 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptLanguageCode.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptLanguageCode.cs @@ -313,5 +313,5 @@ public enum TranscriptLanguageCode Yi, [EnumMember(Value = "yo")] - Yo + Yo, } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptList.cs b/src/AssemblyAI/Transcripts/Types/TranscriptList.cs index 7ff44ad..ff070e2 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptList.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptList.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -12,4 +13,9 @@ public record TranscriptList [JsonPropertyName("transcripts")] public IEnumerable Transcripts { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptListItem.cs b/src/AssemblyAI/Transcripts/Types/TranscriptListItem.cs index 7b0e6b6..42b3c9b 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptListItem.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptListItem.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -29,4 +30,9 @@ public record TranscriptListItem /// [JsonPropertyName("error")] public string? Error { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptOptionalParams.cs b/src/AssemblyAI/Transcripts/Types/TranscriptOptionalParams.cs index b585da0..44158dc 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptOptionalParams.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptOptionalParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -221,4 +222,9 @@ public record TranscriptOptionalParams /// [JsonPropertyName("topics")] public IEnumerable? Topics { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptParagraph.cs b/src/AssemblyAI/Transcripts/Types/TranscriptParagraph.cs index 9988327..0139d2d 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptParagraph.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptParagraph.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -26,4 +27,9 @@ public record TranscriptParagraph /// [JsonPropertyName("speaker")] public string? Speaker { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptReadyNotification.cs b/src/AssemblyAI/Transcripts/Types/TranscriptReadyNotification.cs index 4eaf94b..d56c24a 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptReadyNotification.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptReadyNotification.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -17,4 +18,9 @@ public record TranscriptReadyNotification /// [JsonPropertyName("status")] public required TranscriptReadyStatus Status { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptReadyStatus.cs b/src/AssemblyAI/Transcripts/Types/TranscriptReadyStatus.cs index e8aff14..999ae77 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptReadyStatus.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptReadyStatus.cs @@ -13,5 +13,5 @@ public enum TranscriptReadyStatus Completed, [EnumMember(Value = "error")] - Error + Error, } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptSentence.cs b/src/AssemblyAI/Transcripts/Types/TranscriptSentence.cs index c66a75f..0517bd2 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptSentence.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptSentence.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -26,4 +27,9 @@ public record TranscriptSentence /// [JsonPropertyName("speaker")] public string? Speaker { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptStatus.cs b/src/AssemblyAI/Transcripts/Types/TranscriptStatus.cs index 0e74ec1..9b253d0 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptStatus.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptStatus.cs @@ -19,5 +19,5 @@ public enum TranscriptStatus Completed, [EnumMember(Value = "error")] - Error + Error, } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptUtterance.cs b/src/AssemblyAI/Transcripts/Types/TranscriptUtterance.cs index a9a4a79..e0ae489 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptUtterance.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptUtterance.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -41,4 +42,9 @@ public record TranscriptUtterance /// [JsonPropertyName("speaker")] public required string Speaker { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/TranscriptWord.cs b/src/AssemblyAI/Transcripts/Types/TranscriptWord.cs index fd7a481..88eead3 100644 --- a/src/AssemblyAI/Transcripts/Types/TranscriptWord.cs +++ b/src/AssemblyAI/Transcripts/Types/TranscriptWord.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record TranscriptWord /// [JsonPropertyName("speaker")] public string? Speaker { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/WordSearchMatch.cs b/src/AssemblyAI/Transcripts/Types/WordSearchMatch.cs index e673639..188b1a3 100644 --- a/src/AssemblyAI/Transcripts/Types/WordSearchMatch.cs +++ b/src/AssemblyAI/Transcripts/Types/WordSearchMatch.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -29,4 +30,9 @@ public record WordSearchMatch /// [JsonPropertyName("indexes")] public IEnumerable Indexes { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/AssemblyAI/Transcripts/Types/WordSearchResponse.cs b/src/AssemblyAI/Transcripts/Types/WordSearchResponse.cs index 6a386a9..6f3701d 100644 --- a/src/AssemblyAI/Transcripts/Types/WordSearchResponse.cs +++ b/src/AssemblyAI/Transcripts/Types/WordSearchResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using AssemblyAI.Core; #nullable enable @@ -23,4 +24,9 @@ public record WordSearchResponse /// [JsonPropertyName("matches")] public IEnumerable Matches { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } From 11d601da422224a839fc92bf1cbf48fa89eea281 Mon Sep 17 00:00:00 2001 From: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:33:52 -0400 Subject: [PATCH 2/2] Fix new generated SDK version --- .fernignore | 2 ++ src/AssemblyAI/AssemblyAIClient.cs | 13 ++++--------- .../Core/Public/AssemblyAIException.cs | 9 +++++++-- src/AssemblyAI/Core/Public/ClientOptions.cs | 10 +++++----- .../Core/Public/ExtendedClientOptions.cs | 19 +++++++++++++++++++ .../DependencyInjectionExtensions.cs | 1 + src/AssemblyAI/Realtime/Types/Realtime.cs | 17 ----------------- .../Transcripts/TranscriptsClient.cs | 2 +- 8 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 src/AssemblyAI/Core/Public/ExtendedClientOptions.cs delete mode 100644 src/AssemblyAI/Realtime/Types/Realtime.cs diff --git a/.fernignore b/.fernignore index 84db486..7c90252 100644 --- a/.fernignore +++ b/.fernignore @@ -11,6 +11,7 @@ src/AssemblyAI.sln src/AssemblyAI/AssemblyAI.csproj src/AssemblyAI/Core/JsonConfiguration.cs src/AssemblyAI/Core/Public/ApiException.cs +src/AssemblyAI/Core/Public/AssemblyAIException.cs src/AssemblyAI/Core/CustomConstants.cs src/AssemblyAI/Types/Error.cs src/AssemblyAI/UserAgent.cs @@ -30,6 +31,7 @@ src/AssemblyAI/Realtime/ExtendedRealtimeClient.cs src/AssemblyAI/Realtime/RealtimeTranscriberOptions.cs src/AssemblyAI/Realtime/Types/TerminateSession.cs src/AssemblyAI/Realtime/Types/ForceEndUtterance.cs +src/AssemblyAI/Realtime/Types/Realtime.cs src/AssemblyAI.Test src/AssemblyAI.UnitTests src/AssemblyAI.IntegrationTests diff --git a/src/AssemblyAI/AssemblyAIClient.cs b/src/AssemblyAI/AssemblyAIClient.cs index c9e08ec..9b44122 100644 --- a/src/AssemblyAI/AssemblyAIClient.cs +++ b/src/AssemblyAI/AssemblyAIClient.cs @@ -35,16 +35,11 @@ public AssemblyAIClient(ClientOptions clientOptions) throw new ArgumentException("AssemblyAI API Key is required."); } + // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract clientOptions.HttpClient ??= new HttpClient(); - var client = new RawClient( - new Dictionary - { - ["Authorization"] = clientOptions.ApiKey, - ["User-Agent"] = new UserAgent(UserAgent.Default, clientOptions.UserAgent).ToAssemblyAIUserAgentString() - }, - new Dictionary>(), - clientOptions - ); + clientOptions.Headers.Add("Authorization", clientOptions.ApiKey); + clientOptions.Headers.Add("User-Agent", new UserAgent(UserAgent.Default, clientOptions.UserAgent).ToAssemblyAIUserAgentString()); + var client = new RawClient(clientOptions); Files = new FilesClient(client); Transcripts = new ExtendedTranscriptsClient(client, this); diff --git a/src/AssemblyAI/Core/Public/AssemblyAIException.cs b/src/AssemblyAI/Core/Public/AssemblyAIException.cs index edc89e2..c8aa8df 100644 --- a/src/AssemblyAI/Core/Public/AssemblyAIException.cs +++ b/src/AssemblyAI/Core/Public/AssemblyAIException.cs @@ -7,5 +7,10 @@ namespace AssemblyAI; /// /// Base exception class for all exceptions thrown by the SDK. /// -public class AssemblyAIException(string message, Exception? innerException = null) - : Exception(message, innerException) { } +public class AssemblyAIException : Exception +{ + internal AssemblyAIException(string message, Exception? innerException = null) + : base(message, innerException) + { + } +} diff --git a/src/AssemblyAI/Core/Public/ClientOptions.cs b/src/AssemblyAI/Core/Public/ClientOptions.cs index eb8b087..883e38b 100644 --- a/src/AssemblyAI/Core/Public/ClientOptions.cs +++ b/src/AssemblyAI/Core/Public/ClientOptions.cs @@ -11,22 +11,22 @@ public partial class ClientOptions /// /// The Base URL for the API. /// - public string BaseUrl { get; init; } = AssemblyAIClientEnvironment.Default; + public string BaseUrl { get; set; } = AssemblyAIClientEnvironment.Default; /// /// The http client used to make requests. /// - public HttpClient HttpClient { get; init; } = new HttpClient(); + public HttpClient HttpClient { get; set; } = new HttpClient(); /// - /// The http client used to make requests. + /// The amount to retry sending the HTTP request if it fails. /// - public int MaxRetries { get; init; } = 2; + public int MaxRetries { get; set; } = 2; /// /// The timeout for the request. /// - public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(30); + public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(30); /// /// The http headers sent with the request. diff --git a/src/AssemblyAI/Core/Public/ExtendedClientOptions.cs b/src/AssemblyAI/Core/Public/ExtendedClientOptions.cs new file mode 100644 index 0000000..68369f9 --- /dev/null +++ b/src/AssemblyAI/Core/Public/ExtendedClientOptions.cs @@ -0,0 +1,19 @@ +using System.Net.Http; +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +// ReSharper disable CheckNamespace + +namespace AssemblyAI; + +public partial class ClientOptions +{ + /// + /// The AssemblyAI API key + /// + public required string ApiKey { get; set; } + + /// + /// The AssemblyAI user agent + /// + public UserAgent UserAgent { get; set; } = new(); +} \ No newline at end of file diff --git a/src/AssemblyAI/DependencyInjectionExtensions.cs b/src/AssemblyAI/DependencyInjectionExtensions.cs index 69be8c3..b3d3beb 100644 --- a/src/AssemblyAI/DependencyInjectionExtensions.cs +++ b/src/AssemblyAI/DependencyInjectionExtensions.cs @@ -86,6 +86,7 @@ private static void Validate(OptionsBuilder optionsBuilder) private static AssemblyAIClient CreateAssemblyAIClient(IServiceProvider provider) { var options = provider.GetRequiredService>().Value; + // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract options.HttpClient ??= provider.GetRequiredService().CreateClient(AssemblyAIHttpClientName); return new AssemblyAIClient(options); } diff --git a/src/AssemblyAI/Realtime/Types/Realtime.cs b/src/AssemblyAI/Realtime/Types/Realtime.cs deleted file mode 100644 index a36c002..0000000 --- a/src/AssemblyAI/Realtime/Types/Realtime.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Runtime.Serialization; -using System.Text.Json.Serialization; -using AssemblyAI.Core; - -#nullable enable - -namespace AssemblyAI.Realtime; - -[JsonConverter(typeof(StringEnumSerializer))] -public enum Realtime -{ - [EnumMember(Value = "pcm_s16le")] - PcmS16le, - - [EnumMember(Value = "pcm_mulaw")] - PcmMulaw, -} diff --git a/src/AssemblyAI/Transcripts/TranscriptsClient.cs b/src/AssemblyAI/Transcripts/TranscriptsClient.cs index 61a1773..bcda900 100644 --- a/src/AssemblyAI/Transcripts/TranscriptsClient.cs +++ b/src/AssemblyAI/Transcripts/TranscriptsClient.cs @@ -302,7 +302,7 @@ public async Task GetSubtitlesAsync( { BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"v2/transcript/{transcriptId}/{subtitleFormat}", + Path = $"v2/transcript/{transcriptId}/{subtitleFormat.Stringify()}", Query = _query, Options = options, },