Skip to main content
This guide walks through the process of migrating from Gladia to AssemblyAI for transcribing streaming audio.

Get Started

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 AssemblyAI dashboard.

Side-By-Side Code Comparison

Below is a side-by-side comparison of a basic snippet to transcribe live audio by Gladia and AssemblyAI using a microphone:

Authentication

Protect Your API KeyFor improved security, store your API key as an environment variable.

Connection Parameters & Microphone Setup

Helpful information about our streaming model:
  • Universal-3.5 Pro Model — Connect to wss://streaming.assemblyai.com/v3/ws with speech_model=universal-3-5-pro to use our latest, highest-accuracy streaming model — Universal-3.5 Pro.
  • Built-in Formatting — Universal-3.5 Pro always returns formatted transcripts with smart punctuation & casing. No extra parameter is needed.
  • Partial Transcripts — AssemblyAI streams interim results automatically. Universal-3.5 Pro emits partials during periods of silence, with at most one partial per silence period.

Open Microphone Stream & Create WebSocket

Open WebSocket

Receive Messsages from WebSocket

Helpful information 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 so you can immediately 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.5 Pro always returns formatted transcripts with smart punctuation & casing built in.

Close the WebSocket

Helpful information about AssemblyAI’s WebSocket Closure:
  • Connection Diagnostics - 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 authentication, or encountered a different error.

Session Shutdown

Helpful information 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": "stop_recording" }.
  • No Metadata Race Condition - AssemblyAI provides session info at “Begin” and doesn’t append extra data at shutdown, making the exit faster and less error-prone.

Resources

For additional information about using AssemblyAI’s Streaming Speech-To-Text API you can also refer to: