AssemblyAI has introduced the discharge of its new C# .NET SDK, designed to facilitate audio transcription and evaluation for builders using .NET languages reminiscent of 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 Customary 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 information asynchronously or in real-time. Under is an instance of how you 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 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 function is especially helpful for functions requiring rapid 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 Purposes
The SDK integrates with LeMUR to permit builders to construct giant language mannequin (LLM) functions 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 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 end in 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