Streaming Migration Guide: Deepgram to AssemblyAI
Streaming Migration Guide: Deepgram to AssemblyAI
Streaming Migration Guide: Deepgram to AssemblyAI
This guide walks through the process of migrating from Deepgram to AssemblyAI for transcribing streaming audio.
Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for a free account and get your API key from your dashboard.
Below is a side-by-side comparison of a basic snippet to transcribe live audio by Deepgram and AssemblyAI using a microphone:
When migrating from Deepgram to AssemblyAI, you’ll first need to handle authentication:
Get your API key from your AssemblyAI dashboard
For improved security, store your API key as an environment variable.
Here are helpful things to know about connecting our streaming model:
Universal-3 Pro model — Connect to wss://streaming.assemblyai.com/v3/ws with speech_model=u3-rt-pro to use our latest, highest-accuracy streaming model. Unlike Deepgram’s model="nova-3", you use a single speech_model parameter.
Built-in formatting — Universal-3 Pro always returns formatted transcripts with smart punctuation & casing, similar to Deepgram’s punctuate=true. No extra parameter is needed.
Partials are always on — like Deepgram’s interim_results=true — AssemblyAI streams interim results automatically. Universal-3 Pro emits partials during periods of silence, with at most one partial per silence period.
Tip: Adding error-handling and log lines (as in the AssemblyAI snippet) lets you see exactly when the socket opens, audio starts, or a read fails—catching issues early saving time debugging silent failures.
Helpful things to know about AssemblyAI’s message payloads:
Clear message types – Instead of checking is_final, you’ll receive explicit "Begin", "Turn", and "Termination" events, making your logic simpler and more readable.
Session metadata up-front – The first "Begin" message delivers a session_id and expiry timestamp. You can log or surface these for tracing or billing.
End-of-turn detection – Each "Turn" object includes an end_of_turn boolean. When end_of_turn is true, the transcript is a final, formatted result. When false, it is a partial transcript. Universal-3 Pro always returns formatted transcripts with smart punctuation & casing built in.
Capture and log any errors emitted by the WebSocket connection to streamline troubleshooting and maintain smooth operation.
Helpful things to know about AssemblyAI’s WebSocket Closure:
Connection diagnostics on tap - If the socket closes unexpectedly, AssemblyAI supplies both a status code and a reason message (close_status_code, close_msg), so you know immediately whether the server timed out, refused auth, or encountered another error.
Metadata arrives at session start, not at close - Deepgram sends its final metadata only when the socket closes. AssemblyAI delivers session information up front in the initial “Begin” message, so you can log IDs and expiry times right away.
Helpful things to know about AssemblyAI’s shutdown:
JSON payload difference - When closing the stream with AssemblyAI, your JSON payload will be {"type: "Terminate" } instead of {"type: "CloseStream" }
No metadata race condition - Because AssemblyAI already provided session info at “Begin” and doesn’t append extra data at shutdown, you don’t have to sleep (time.sleep(0.5)) to wait for “final metadata” before closing—making the exit faster and less error-prone.
For additional information about using AssemblyAI’s Streaming Speech-To-Text API you can also refer to: