Luisa Crawford
Sep 03, 2024 05:37
AssemblyAI releases a C# .NET SDK, enabling builders to transcribe and analyze audio, and apply LLMs utilizing LeMUR.
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, in response to AssemblyAI.
Key Options and Targets
The SDK has been developed with a number of key targets 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 Commonplace 2.0 and above.
- Decrease dependencies to stop model conflicts and the necessity for binding redirects.
Transcribing Audio Recordsdata
One of many major functionalities of the SDK is audio transcription. Builders can transcribe audio recordsdata asynchronously or in real-time. Beneath is an instance of the way to transcribe an audio file:
utilizing AssemblyAI;
utilizing AssemblyAI.Transcripts;
var consumer = new AssemblyAIClient("YOUR_API_KEY");
var transcript = await consumer.Transcripts.TranscribeAsync(new TranscriptParams
{
AudioUrl = "https://storage.googleapis.com/aai-docs-samples/nbc.mp3"
});
transcript.EnsureStatusCompleted();
Console.WriteLine(transcript.Textual content);
For native recordsdata, comparable code can be utilized to realize transcription.
await utilizing var stream = new FileStream("./nbc.mp3", FileMode.Open);
var transcript = await consumer.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 purposes requiring speedy processing of audio knowledge.
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($"Closing: {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 massive language mannequin (LLM) purposes on voice knowledge. 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 consumer.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 consumer.Transcripts.TranscribeAsync(new TranscriptParams
{
AudioUrl = "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
SentimentAnalysis = true
});
foreach (var end in 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


