diff --git a/.fernignore b/.fernignore index de9c6c0..c7991b8 100644 --- a/.fernignore +++ b/.fernignore @@ -7,7 +7,6 @@ AssemblyAI/Realtime/WebSocketClient src/AssemblyAI/AssemblyAIClient.cs src/AssemblyAI/Files/FilesCustomClient.cs src/AssemblyAI/Transcripts/TranscriptsCustomClient.cs -src/AssemblyAI/Transcripts/TranscriptsClient.cs src/AssemblyAI/Transcripts/Requests/ListTranscriptParams.cs diff --git a/.gitignore b/.gitignore index dd71f89..f5cad14 100644 --- a/.gitignore +++ b/.gitignore @@ -476,4 +476,6 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -.runsettings \ No newline at end of file +.idea +.runsettings + diff --git a/src/AssemblyAI.Test/TestData/nbc.mp3 b/src/AssemblyAI.Test/TestData/nbc.mp3 new file mode 100644 index 0000000..50ff56f Binary files /dev/null and b/src/AssemblyAI.Test/TestData/nbc.mp3 differ diff --git a/src/AssemblyAI/AssemblyAIClient.cs b/src/AssemblyAI/AssemblyAIClient.cs index f8c3e62..51a6b96 100644 --- a/src/AssemblyAI/AssemblyAIClient.cs +++ b/src/AssemblyAI/AssemblyAIClient.cs @@ -22,14 +22,14 @@ public AssemblyAIClient(string? apiKey = null, ClientOptions? clientOptions = nu clientOptions ?? new ClientOptions() ); Files = new FilesClient(_client); - Transcripts = new TranscriptsClient(_client, this); + Transcripts = new ExtendedTranscriptsClient(_client, this); Realtime = new RealtimeClient(_client); Lemur = new LemurClient(_client); } public FilesClient Files { get; init; } - public TranscriptsClient Transcripts { get; init; } + public ExtendedTranscriptsClient Transcripts { get; init; } public RealtimeClient Realtime { get; init; } diff --git a/src/AssemblyAI/Transcripts/TranscriptsCustomClient.cs b/src/AssemblyAI/Transcripts/ExtendedTranscriptsClient.cs similarity index 93% rename from src/AssemblyAI/Transcripts/TranscriptsCustomClient.cs rename to src/AssemblyAI/Transcripts/ExtendedTranscriptsClient.cs index bf32d35..3649017 100644 --- a/src/AssemblyAI/Transcripts/TranscriptsCustomClient.cs +++ b/src/AssemblyAI/Transcripts/ExtendedTranscriptsClient.cs @@ -1,8 +1,10 @@ #nullable enable +using AssemblyAI.Core; + namespace AssemblyAI; -public partial class TranscriptsClient +public class ExtendedTranscriptsClient(RawClient client, AssemblyAIClient assemblyAIClient) : TranscriptsClient(client) { public Task SubmitAsync(FileInfo audioFile) => SubmitAsync(audioFile, new TranscriptOptionalParams()); @@ -17,7 +19,7 @@ public Task SubmitAsync(Stream audioFileStream) => public async Task SubmitAsync(Stream audioFileStream, TranscriptOptionalParams transcriptParams) { - var fileUpload = await _assemblyAIClient.Files.UploadAsync(audioFileStream).ConfigureAwait(false); + var fileUpload = await assemblyAIClient.Files.UploadAsync(audioFileStream).ConfigureAwait(false); return await SubmitAsync(new Uri(fileUpload.UploadUrl), transcriptParams).ConfigureAwait(false); } @@ -42,7 +44,7 @@ public Task TranscribeAsync(Stream audioFileStream) => public async Task TranscribeAsync(Stream audioFileStream, TranscriptOptionalParams transcriptParams) { - var fileUpload = await _assemblyAIClient.Files.UploadAsync(audioFileStream).ConfigureAwait(false); + var fileUpload = await assemblyAIClient.Files.UploadAsync(audioFileStream).ConfigureAwait(false); return await TranscribeAsync(new Uri(fileUpload.UploadUrl), transcriptParams).ConfigureAwait(false); } @@ -88,7 +90,7 @@ public async Task ListAsync(string listUrl) // this would be easier to just call the given URL, // but the raw client doesn't let us make requests to full URL // so we'll parse the querystring and pass it to `ListAsync`. - + var queryString = listUrl.Substring(listUrl.IndexOf('?') + 1) .Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries) .Select(k => k.Split('=')) @@ -116,17 +118,17 @@ public async Task ListAsync(string listUrl) { listTranscriptParams.BeforeId = queryString["before_id"].First(); } - + if (queryString.Contains("after_id")) { listTranscriptParams.AfterId = queryString["after_id"].First(); } - + if (queryString.Contains("throttled_only")) { listTranscriptParams.ThrottledOnly = bool.Parse(queryString["throttled_only"].First()); } - + return await ListAsync(listTranscriptParams).ConfigureAwait(false); } } \ No newline at end of file diff --git a/src/AssemblyAI/Transcripts/TranscriptsClient.cs b/src/AssemblyAI/Transcripts/TranscriptsClient.cs index 7a2b3bc..f16782d 100644 --- a/src/AssemblyAI/Transcripts/TranscriptsClient.cs +++ b/src/AssemblyAI/Transcripts/TranscriptsClient.cs @@ -7,15 +7,13 @@ namespace AssemblyAI; -public partial class TranscriptsClient +public class TranscriptsClient { private RawClient _client; - private readonly AssemblyAIClient _assemblyAIClient; - public TranscriptsClient(RawClient client, AssemblyAIClient assemblyAIClient) + public TranscriptsClient(RawClient client) { _client = client; - _assemblyAIClient = assemblyAIClient; } ///