AssemblyAI has introduced the discharge of its new C# .NET SDK, designed to facilitate audio transcription and evaluation for builders using .NET languages equivalent to C#, VB.NET, and F#. The SDK goals to streamline using AssemblyAI’s superior Speech AI fashions, based on AssemblyAI.
Key Options and Targets
The SDK has been developed with a number of key goals in thoughts:
- Present an intuitive interface for all AssemblyAI fashions and options utilizing idiomatic C#.
- Guarantee compatibility with a number of frameworks, together with .NET 6.0, .NET Framework 4.6.2, and .NET Normal 2.0 and above.
- Decrease dependencies to forestall model conflicts and the necessity for binding redirects.
Transcribing Audio Information
One of many main functionalities of the SDK is audio transcription. Builders can transcribe audio information asynchronously or in real-time. Under is an instance of how one can transcribe an audio file:
utilizing AssemblyAI;
utilizing AssemblyAI.Transcripts;
var shopper = new AssemblyAIClient("YOUR_API_KEY");
var transcript = await shopper.Transcripts.TranscribeAsync(new TranscriptParams
{
AudioUrl = "https://storage.googleapis.com/aai-docs-samples/nbc.mp3"
});
transcript.EnsureStatusCompleted();
Console.WriteLine(transcript.Textual content);
For native information, related code can be utilized to attain transcription.
await utilizing var stream = new FileStream("./nbc.mp3", FileMode.Open);
var transcript = await shopper.Transcripts.TranscribeAsync(
stream,
new TranscriptOptionalParams
{
LanguageCode = TranscriptLanguageCode.EnUs
}
);
transcript.EnsureStatusCompleted();
Console.WriteLine(transcript.Textual content);
Actual-Time Audio Transcription
The SDK additionally helps real-time audio transcription utilizing Streaming Speech-to-Textual content. This characteristic is especially helpful for functions requiring speedy processing of audio information.
utilizing AssemblyAI.Realtime;
await utilizing var transcriber = new RealtimeTranscriber(new RealtimeTranscriberOptions
{
ApiKey = "YOUR_API_KEY",
SampleRate = 16_000
});
transcriber.PartialTranscriptReceived.Subscribe(transcript =>
{
Console.WriteLine($"Partial: {transcript.Textual content}");
});
transcriber.FinalTranscriptReceived.Subscribe(transcript =>
{
Console.WriteLine($"Ultimate: {transcript.Textual content}");
});
await transcriber.ConnectAsync();
// Pseudocode for getting audio from a microphone for instance
GetAudio(async (chunk) => await transcriber.SendAudioAsync(chunk));
await transcriber.CloseAsync();
Using LeMUR for LLM Functions
The SDK integrates with LeMUR to permit builders to construct giant language mannequin (LLM) functions on voice information. Right here is an instance:
var lemurTaskParams = new LemurTaskParams
{
Immediate = "Present a quick abstract of the transcript.",
TranscriptIds = [transcript.Id],
FinalModel = LemurModel.AnthropicClaude3_5_Sonnet
};
var response = await shopper.Lemur.TaskAsync(lemurTaskParams);
Console.WriteLine(response.Response);
Audio Intelligence Fashions
Moreover, the SDK comes with built-in assist for audio intelligence fashions, enabling sentiment evaluation and different superior options.
var transcript = await shopper.Transcripts.TranscribeAsync(new TranscriptParams
{
AudioUrl = "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
SentimentAnalysis = true
});
foreach (var lead to transcript.SentimentAnalysisResults!)
{
Console.WriteLine(outcome.Textual content);
Console.WriteLine(outcome.Sentiment); // POSITIVE, NEUTRAL, or NEGATIVE
Console.WriteLine(outcome.Confidence);
Console.WriteLine($"Timestamp: {outcome.Begin} - {outcome.Finish}");
}
For extra info, go to the official AssemblyAI weblog.
Picture supply: Shutterstock