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:
-
One Universal Model - Just connect to
wss://streaming.assemblyai.com/v3/ws
. The live endpoint always uses our latest, best-performing model. -
Formatted Finals - When
format_turns
is set toTrue
, every Final message arrives with smart punctuation & casing. Set it toFalse
(or omit it) to get raw lowercase text—useful if you do your own formatting. -
Partial Transcripts - AssemblyAI streams immutable interim results automatically. There’s no switch to toggle. Expect fast, token-level updates that refine until each Final is emitted.
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_id
and expiry timestamp so you can immediately log or surface these for tracing or billing. -
Formatted vs. Raw Finals – Each
"Turn"
object includes a booleanturn_is_formatted
. When you setformat_turns
toTrue
, punctuation/casing appears in the Final Transcript, so you can toggle display styles on the fly.
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" }
. -
Server Handles Idle Timeouts - If you forget to send
Terminate
, AssemblyAI will close the socket after an idle window of one minute. -
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: