Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 2fa92fb

Browse files
committed
Add client.Transcripts.GetRedactedAudioFileAsync
1 parent 432faf7 commit 2fa92fb

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

src/AssemblyAI.IntegrationTests/TranscriptsClientTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,17 @@ public async Task Should_Get_Redacted_Audio()
314314
}).ConfigureAwait(false);
315315

316316
var redactedAudioResponse = await client.Transcripts.GetRedactedAudioAsync(transcript.Id).ConfigureAwait(false);
317+
318+
var redactedAudioFileStream = await client.Transcripts.GetRedactedAudioFileAsync(transcript.Id).ConfigureAwait(false);
319+
var memoryStream = new MemoryStream();
320+
await redactedAudioFileStream.CopyToAsync(memoryStream).ConfigureAwait(false);
317321

318322
Assert.Multiple(() =>
319323
{
320324
Assert.That(redactedAudioResponse.Status, Is.EqualTo("redacted_audio_ready"));
321325
Assert.That(redactedAudioResponse.RedactedAudioUrl, Is.Not.Empty);
326+
Assert.That(memoryStream, Is.Not.Null);
327+
Assert.That(memoryStream.Length, Is.GreaterThan(0));
322328
});
323329
}
324330

src/AssemblyAI/AssemblyAI.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
<RootNamespace>AssemblyAI</RootNamespace>
1010
<AssemblyName>AssemblyAI</AssemblyName>
1111
<PackageId>AssemblyAI</PackageId>
12-
<Version>1.0.0</Version>
12+
<Version>1.0.1</Version>
13+
<AssemblyVersion>1.0.1.0</AssemblyVersion>
14+
<FileVersion>1.0.1.0</FileVersion>
15+
<PackageVersion>1.0.1</PackageVersion>
1316
<Title>AssemblyAI C# .NET SDK</Title>
1417
<Authors>AssemblyAI</Authors>
1518
<Description>The AssemblyAI C# .NET SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, audio intelligence models, as well as the latest LeMUR models.</Description>
1619
<Copyright>Copyright 2024 (c) AssemblyAI, Inc. All rights reserved.</Copyright>
1720
<PackageTags>ASR;Speech-To-Text;STT;Speech;AI;AssemblyAI</PackageTags>
1821
<Company>AssemblyAI</Company>
1922
<Product>AssemblyAI</Product>
20-
<AssemblyVersion>1.0.0.3</AssemblyVersion>
21-
<FileVersion>1.0.0.3</FileVersion>
22-
<PackageVersion>1.0.0</PackageVersion>
2323
<OutputType>Library</OutputType>
2424
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2525
<PackageProjectUrl>https://github.com/AssemblyAI/assemblyai-csharp-sdk</PackageProjectUrl>

src/AssemblyAI/Core/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace AssemblyAI.Core;
22

33
internal static class Constants
44
{
5-
internal const string Version = "1.0.0";
5+
internal const string Version = "1.0.1";
66
internal const string DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK";
77
}

src/AssemblyAI/Transcripts/ExtendedTranscriptsClient.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Net.Http;
12
using System.Text.Json;
23
using System.Text.Json.Nodes;
34
using AssemblyAI.Core;
@@ -8,10 +9,12 @@ namespace AssemblyAI.Transcripts;
89

910
public class ExtendedTranscriptsClient : TranscriptsClient
1011
{
12+
private readonly RawClient _client;
1113
private readonly AssemblyAIClient _assemblyAIClient;
1214

1315
internal ExtendedTranscriptsClient(RawClient client, AssemblyAIClient assemblyAIClient) : base(client)
1416
{
17+
_client = client;
1518
_assemblyAIClient = assemblyAIClient;
1619
}
1720

@@ -198,6 +201,19 @@ int charsPerCaption
198201
CharsPerCaption = charsPerCaption
199202
});
200203

204+
/// <summary>
205+
/// Retrieve the redacted audio file.
206+
/// </summary>
207+
public async Task<Stream> GetRedactedAudioFileAsync(
208+
string transcriptId,
209+
RequestOptions? options = null
210+
)
211+
{
212+
var redactedAudioFileInfo = await GetRedactedAudioAsync(transcriptId, options).ConfigureAwait(false);
213+
var httpClient = options?.HttpClient ?? _client.Options.HttpClient ?? new HttpClient();
214+
return await httpClient.GetStreamAsync(redactedAudioFileInfo.RedactedAudioUrl).ConfigureAwait(false);
215+
}
216+
201217
/// <summary>
202218
/// Search through the transcript for keywords. You can search for individual words, numbers, or phrases containing up to five words or numbers.
203219
/// </summary>

0 commit comments

Comments
 (0)