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 line with 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 Normal 2.0 and above.
Reduce dependencies to stop model conflicts and the necessity for binding redirects.
Transcribing Audio Information
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 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 recordsdata, comparable code can be utilized to realize 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 purposes requiring fast 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($”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 information. Right here is an instance:
var lemurTaskParams = new LemurTaskParams
{
Immediate = “Present a short 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 help 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(consequence.Textual content);
Console.WriteLine(consequence.Sentiment); // POSITIVE, NEUTRAL, or NEGATIVE
Console.WriteLine(consequence.Confidence);
Console.WriteLine($”Timestamp: {consequence.Begin} – {consequence.Finish}”);
}
For extra data, go to the official AssemblyAI weblog.
Picture supply: Shutterstock