Skip to content

Commit

Permalink
Add client.Transcripts.GetRedactedAudioFileAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Aug 15, 2024
1 parent 432faf7 commit 2fa92fb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/AssemblyAI.IntegrationTests/TranscriptsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,17 @@ public async Task Should_Get_Redacted_Audio()
}).ConfigureAwait(false);

var redactedAudioResponse = await client.Transcripts.GetRedactedAudioAsync(transcript.Id).ConfigureAwait(false);

var redactedAudioFileStream = await client.Transcripts.GetRedactedAudioFileAsync(transcript.Id).ConfigureAwait(false);
var memoryStream = new MemoryStream();
await redactedAudioFileStream.CopyToAsync(memoryStream).ConfigureAwait(false);

Assert.Multiple(() =>
{
Assert.That(redactedAudioResponse.Status, Is.EqualTo("redacted_audio_ready"));
Assert.That(redactedAudioResponse.RedactedAudioUrl, Is.Not.Empty);
Assert.That(memoryStream, Is.Not.Null);
Assert.That(memoryStream.Length, Is.GreaterThan(0));
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/AssemblyAI/AssemblyAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
<RootNamespace>AssemblyAI</RootNamespace>
<AssemblyName>AssemblyAI</AssemblyName>
<PackageId>AssemblyAI</PackageId>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>
<PackageVersion>1.0.1</PackageVersion>
<Title>AssemblyAI C# .NET SDK</Title>
<Authors>AssemblyAI</Authors>
<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>
<Copyright>Copyright 2024 (c) AssemblyAI, Inc. All rights reserved.</Copyright>
<PackageTags>ASR;Speech-To-Text;STT;Speech;AI;AssemblyAI</PackageTags>
<Company>AssemblyAI</Company>
<Product>AssemblyAI</Product>
<AssemblyVersion>1.0.0.3</AssemblyVersion>
<FileVersion>1.0.0.3</FileVersion>
<PackageVersion>1.0.0</PackageVersion>
<OutputType>Library</OutputType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/AssemblyAI/assemblyai-csharp-sdk</PackageProjectUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/AssemblyAI/Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace AssemblyAI.Core;

internal static class Constants
{
internal const string Version = "1.0.0";
internal const string Version = "1.0.1";
internal const string DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK";
}
16 changes: 16 additions & 0 deletions src/AssemblyAI/Transcripts/ExtendedTranscriptsClient.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Net.Http;
using System.Text.Json;
using System.Text.Json.Nodes;
using AssemblyAI.Core;
Expand All @@ -8,10 +9,12 @@ namespace AssemblyAI.Transcripts;

public class ExtendedTranscriptsClient : TranscriptsClient
{
private readonly RawClient _client;
private readonly AssemblyAIClient _assemblyAIClient;

internal ExtendedTranscriptsClient(RawClient client, AssemblyAIClient assemblyAIClient) : base(client)
{
_client = client;
_assemblyAIClient = assemblyAIClient;
}

Expand Down Expand Up @@ -198,6 +201,19 @@ int charsPerCaption
CharsPerCaption = charsPerCaption
});

/// <summary>
/// Retrieve the redacted audio file.
/// </summary>
public async Task<Stream> GetRedactedAudioFileAsync(
string transcriptId,
RequestOptions? options = null
)
{
var redactedAudioFileInfo = await GetRedactedAudioAsync(transcriptId, options).ConfigureAwait(false);
var httpClient = options?.HttpClient ?? _client.Options.HttpClient ?? new HttpClient();
return await httpClient.GetStreamAsync(redactedAudioFileInfo.RedactedAudioUrl).ConfigureAwait(false);
}

/// <summary>
/// Search through the transcript for keywords. You can search for individual words, numbers, or phrases containing up to five words or numbers.
/// </summary>
Expand Down

0 comments on commit 2fa92fb

Please sign in to comment.