New AssemblyAI-TTS-1: Text-to-speech for voice agents. Learn more
Insights & Use Cases

How to use AssemblyAI with C#

Use AssemblyAI's Voice AI models from C# with the built-in HttpClient — transcribe files, stream audio in real time over WebSocket, apply LLMs with LLM Gateway, and analyze sentiment.

Abstract green cylinder illustration

Written by

Martin Schweiger

Published on

21 August 2026

Learn how to use AssemblyAI's Voice AI models directly with C# using the built-in HttpClient. Transcribe audio, analyze audio using audio intelligence models, and apply LLMs to your audio data using LLM Gateway.

1. Transcribe an audio file

You can also transcribe a local file, as shown here.

2. Transcribe audio in real-time using Streaming Speech-to-Text

3. Use LLM Gateway to build LLM apps on voice data

Learn how to use LLMs with audio data using LLM Gateway in our docs.

4. Use Speech Understanding models

Learn more about our Speech Understanding models in our docs.

Frequently asked questions

Should I use System.Speech or a cloud speech-to-text API in C#?

Use a cloud API for anything beyond simple Windows desktop command recognition. System.Speech.Recognition runs in-process on the Microsoft Speech API and is Windows-only — the NuGet package states plainly that it is not supported on other platforms — and its accuracy on natural conversational audio is far behind current models. A cloud API is a plain HTTP call from any .NET target and gives you punctuation, speaker labels, and modern accuracy without shipping a recognition engine.

Does C# speech-to-text work on Linux and macOS?

Yes, if you call a cloud API rather than a Windows-native library. The code in this guide uses HttpClient and ClientWebSocket from the .NET base class library, both fully cross-platform, so the same project runs on Linux containers, macOS, and Windows unchanged. The platform limitation people run into comes from System.Speech, which is Windows-only — nothing about .NET itself restricts speech-to-text to Windows.

Do I need a NuGet package to use a speech-to-text API in C#?

No. AssemblyAI's API is plain HTTP and WebSocket, so System.Net.Http.Json and System.Net.WebSockets in the base class library are enough — you POST to https://api.assemblyai.com/v2/transcript with your key in the Authorization header and read the JSON response, exactly as shown above. AssemblyAI also publishes a .NET SDK if you'd rather have typed request and response models and less boilerplate; the no-dependency path shown here is useful when you want to see the API surface directly or minimize your dependency tree.

How do I transcribe audio in real time in C#?

Open a ClientWebSocket to wss://streaming.assemblyai.com/v3/ws, set your API key with Options.SetRequestHeader("Authorization", ...), and send raw PCM16 mono audio at 16kHz as binary frames in roughly 50ms chunks. Messages come back as JSON with a type of Begin, Turn, or Termination — each Turn carries the running transcript and an end_of_turn flag telling you when the speaker finished. Send {"type": "Terminate"} before closing the socket, since streaming sessions bill by connection duration.

Are transcripts returned immediately, or do I need to poll?

Transcription is asynchronous: submitting returns a transcript ID right away, and the transcript is ready a short time later. The examples here poll GET /v2/transcript/{id} with await Task.Delay(3000) until status is completed, which is the simplest thing that works. For production, pass a webhook_url on submit and AssemblyAI POSTs to your endpoint when processing finishes — no polling loop, no idle tasks.

Is there a free C# speech-to-text API?

System.Speech is free and built into Windows, but it's Windows-only and its accuracy on real-world audio doesn't hold up for production use. Cloud providers including AssemblyAI offer free credits rather than a permanently free tier, which is enough to build and test a full integration before paying anything. Self-hosted open-source models are the genuinely free option, but you take on GPU cost, deployment, and maintenance in exchange.