Streaming Migration Guide: Gladia to AssemblyAI
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:
Gladia
AssemblyAI
Authentication
Gladia
AssemblyAI
Protect Your API Key
For improved security, store your API key as an environment variable.
Connection Parameters & Microphone Setup
Gladia
AssemblyAI
Helpful information about our streaming model:
-
Universal-3 Pro Model — Connect to
wss://streaming.assemblyai.com/v3/wswithspeech_model=u3-rt-proto use our latest, highest-accuracy streaming model — Universal-3 Pro. -
Built-in Formatting — Universal-3 Pro always returns formatted transcripts with smart punctuation & casing. No extra parameter is needed.
-
Partial Transcripts — AssemblyAI streams interim results automatically. Universal-3 Pro emits partials during periods of silence, with at most one partial per silence period.
Open Microphone Stream & Create WebSocket
Gladia
AssemblyAI
Open WebSocket
Gladia
AssemblyAI
Receive Messsages from WebSocket
Gladia
AssemblyAI
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 asession_idand expiry timestamp so you can immediately log or surface these for tracing or billing. -
End-of-Turn Detection – Each
"Turn"object includes anend_of_turnboolean. Whenend_of_turnistrue, the transcript is a final, formatted result. Whenfalse, it is a partial transcript. Universal-3 Pro always returns formatted transcripts with smart punctuation & casing built in.
Close the WebSocket
Gladia
AssemblyAI
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
Gladia
AssemblyAI
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: