- Fully generated C# SDK based on official AssemblyAI OpenAPI specification using OpenApiGenerator
- Same day update to support new features
- Updated and supported automatically if there are no breaking changes
- All modern .NET features - nullability, trimming, NativeAOT, etc.
- Support .Net Framework/.Net Standard 2.0
- Microsoft.Extensions.AI
ISpeechToTextClientsupport
usingAssemblyAI;usingvarapi=newAssemblyAIClient(apiKey);varfileUrl="https://github.com/AssemblyAI-Community/audio-examples/raw/main/20230607_me_canadian_wildfires.mp3";//// You can also transcribe a local file by passing in a file path// var filePath = "./path/to/file.mp3";// var uploadedFile = await api.Files.UploadAsync(await File.ReadAllBytesAsync(filePath));// fileUrl = uploadedFile.UploadUrl;varqueued=awaitapi.Transcripts.SubmitAsync(TranscriptParams.FromUrl(fileUrl,newTranscriptOptionalParams{SpeechModels=[SpeechModel2.Universal35Pro],LanguageDetection=true,// Enables native code-switching routing.SpeakerLabels=true,// Speaker diarization.Prompt="Canadian wildfire news interview with air quality and public health terms.",KeytermsPrompt=["Peter DeCarlo","Johns Hopkins","particulate matter"],}));Transcripttranscript;do{awaitTask.Delay(TimeSpan.FromSeconds(2));transcript=awaitapi.Transcripts.GetAsync(queued.Id.ToString());}while(transcript.StatusisTranscriptStatus.Queued or TranscriptStatus.Processing);transcript.EnsureStatusCompleted();Console.WriteLine(transcript);The SDK implements ISpeechToTextClient:
usingAssemblyAI;usingMicrosoft.Extensions.AI;ISpeechToTextClientspeechClient=newAssemblyAIClient(apiKey);awaitusingvaraudioStream=File.OpenRead("recording.wav");varresponse=awaitspeechClient.GetTextAsync(audioStream);Console.WriteLine(response.Text);usingvarclient=GetAuthenticatedApi();varfileUrl="https://github.com/AssemblyAI-Community/audio-examples/raw/main/20230607_me_canadian_wildfires.mp3";// You can also transcribe a local file by passing in a file path// var filePath = "./path/to/file.mp3";// var uploadedFile = await client.Files.UploadAsync(await File.ReadAllBytesAsync(filePath));// fileUrl = uploadedFile.UploadUrl;varqueued=awaitclient.Transcripts.SubmitAsync(TranscriptParams.FromUrl(fileUrl,newTranscriptOptionalParams{SpeechModels=[SpeechModel2.Universal35Pro],LanguageDetection=true,SpeakerLabels=true,AutoHighlights=true,}));vartranscript=awaitPollUntilTerminalAsync(client,queued.Id);transcript.EnsureStatusCompleted();Console.WriteLine(transcript);// If you want to summarize the transcript, you can use the Lemur API// LemurTaskResponse response = await client.LeMUR.LemurTaskAsync(LemurTaskParams.FromPrompt(// prompt: "Provide a brief summary of the transcript.",// @params: new LemurBaseParams// {// TranscriptIds = [transcript.Id],// FinalModel = LemurModel.AnthropicClaude35Sonnet// }));//// Console.WriteLine(response.String?.Value1?.Response ?? "No response found.");// Console.WriteLine($"Input tokens: {response.String?.Value2?.Usage.InputTokens}");// Console.WriteLine($"Input tokens: {response.String?.Value2?.Usage.OutputTokens}");usingvarclient=GetAuthenticatedApi();// - You need to have `sox` installed on your system. If not, run:// macOS: brew install sox (macOS)// Linux: sudo apt-get install sox libsox-fmt-all// Windows: manually download and install sox, and add sox to your PATH environment variable.// https://sourceforge.net/projects/sox/// Set up the cancellation token, so we can stop the program with Ctrl+Cvarcts=newCancellationTokenSource();varct=cts.Token;Console.CancelKeyPress+=(sender,e)=>cts.Cancel();// Set up the realtime transcriber// await using var transcriber = new RealtimeTranscriber(new RealtimeTranscriberOptions// {// SampleRate = 16_000// });//// transcriber.PartialTranscriptReceived.Subscribe(transcript =>// {// if (transcript.Text == "") return;// Console.WriteLine($"Partial transcript: {transcript.Text}");// });// transcriber.FinalTranscriptReceived.Subscribe(transcript =>// {// Console.WriteLine($"Final transcript: {transcript.Text}");// });//await transcriber.ConnectAsync();varsoxArguments=string.Join(' ',[// --default-device doesn't work on WindowsOperatingSystem.IsWindows()?"-t waveaudio default":"--default-device","--no-show-progress","--rate 16000","--channels 1","--encoding signed-integer","--bits 16","--type wav","-"// pipe]);Console.WriteLine($"sox {soxArguments}");usingvarsoxProcess=newProcess();soxProcess.StartInfo=newProcessStartInfo{FileName="sox",Arguments=soxArguments,RedirectStandardOutput=true,RedirectStandardError=true,UseShellExecute=false,CreateNoWindow=true};soxProcess.Start();soxProcess.BeginErrorReadLine();varsoxOutputStream=soxProcess.StandardOutput.BaseStream;varbuffer=newMemory<byte>(newbyte[4096]);while(awaitsoxOutputStream.ReadAsync(buffer,ct)>0){if(ct.IsCancellationRequested)break;//await transcriber.SendAudioAsync(buffer);}soxProcess.Kill();//await transcriber.CloseAsync();This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.
Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.
Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.
Priority place for bugs: https://github.com/tryAGI/AssemblyAI/issues
Priority place for ideas and general questions: https://github.com/tryAGI/AssemblyAI/discussions
Discord: https://discord.gg/Ca2xhfBf3v
This project is supported by JetBrains through the Open Source Support Program.
