Skip to content

Commit 656966e

Browse files
committed
Add assembly migration guide
1 parent 4a599bc commit 656966e

File tree

2 files changed

+353
-3
lines changed

2 files changed

+353
-3
lines changed
Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
---
2+
title: "Quick migration guide: realtime STT from AssemblyAI to Gladia"
3+
description: "Guide to seamlessly switch your realtime WebSocket transcription from AssemblyAI's SDK to Gladia's SDK."
4+
sidebarTitle: "From AssemblyAI"
5+
---
6+
7+
This step-by-step guide shows how to switch your realtime transcription from AssemblyAI to Gladia with minimal code changes. It highlights equivalences, subtle differences, and drop‑in replacements so you can migrate quickly and confidently, without any regressions.
8+
9+
## Step-by-step guide
10+
11+
### Install the SDK
12+
13+
Install the official SDKs to enable realtime streaming. That's all you need to get started in Python or TypeScript.
14+
15+
_For AssemblyAI :_
16+
17+
<CodeGroup>
18+
19+
```bash Python
20+
pip install assemblyai
21+
```
22+
23+
```bash Typescript
24+
npm i assemblyai
25+
```
26+
27+
</CodeGroup>
28+
29+
_For Gladia:_
30+
31+
<CodeGroup>
32+
33+
```bash Python
34+
pip install gladiaio-sdk
35+
```
36+
37+
```bash Typescript
38+
npm i @gladiaio/sdk
39+
```
40+
41+
</CodeGroup>
42+
43+
### Initialize the client
44+
45+
Create and authenticate the client that manages your live connection. The shape is the same idea across providers—just swap the client and key.
46+
47+
_For AssemblyAI :_
48+
49+
<CodeGroup>
50+
51+
```python Python
52+
from assemblyai.streaming.v3 import StreamingClient, StreamingClientOptions
53+
54+
api_key = "<YOUR_ASSEMBLYAI_API_KEY>"
55+
56+
assemblyClient = StreamingClient(
57+
StreamingClientOptions(
58+
api_key=api_key,
59+
api_host="streaming.assemblyai.com",
60+
)
61+
)
62+
```
63+
64+
```typescript Typescript
65+
import { AssemblyAI } from "assemblyai";
66+
67+
const assemblyClient = new AssemblyAI({
68+
apiKey: process.env.ASSEMBLYAI_API_KEY!,
69+
});
70+
```
71+
72+
</CodeGroup>
73+
74+
_For Gladia :_
75+
76+
<CodeGroup>
77+
78+
```python Python
79+
from gladiaio_sdk import GladiaClient
80+
81+
gladia_client = GladiaClient(api_key="<YOUR_GLADIA_API_KEY>")
82+
```
83+
84+
```typescript Typescript
85+
import { GladiaClient } from "@gladiaio/sdk";
86+
87+
const gladiaClient = new GladiaClient({
88+
apiKey: process.env.GLADIA_API_KEY,
89+
});
90+
```
91+
92+
</CodeGroup>
93+
94+
### Configure the session
95+
96+
Choose the model, audio format, and language options your app needs. Most parameters map one‑to‑one, so your existing settings carry over naturally.
97+
98+
#### AssemblyAI to Gladia parameter mapping
99+
100+
| AssemblyAI | Gladia | Notes / Example |
101+
| :---------------: | :---------------------------------------------------: | --------------------------------------------------------------------------------------------------------------------- |
102+
| `model` | `model` | Choose the latest Gladia model ("solaria-1"). |
103+
| `encoding` | `encoding` | Match the actual [audio format](/api-reference/v2/live/init#body-encoding) (e.g., `linear16``wav/pcm`). |
104+
| | `bit_depth` | Choose the [bit depth](/api-reference/v2/live/init#body-bit-depth) value from your audio |
105+
| `sample_rate` | `sample_rate` | Same unit (Hz). |
106+
| `channels` | `channels` | Same meaning. |
107+
| `interim_results` | `messages_config.receive_partial_transcripts` | Set `true` to receive [partials messages](/chapters/live-stt/features/partial-transcripts). |
108+
| `endpointing` | `endpointing`; `maximum_duration_without_endpointing` | Port thresholds and consider a hard cap. |
109+
| `language` | `language_config.languages` (+ `code_switching`) | Pass one or more languages; enable switching when [multiple languages](/chapters/language/code-switching) are spoken. |
110+
111+
```json Gladia config example
112+
{
113+
"model": "solaria-1",
114+
"encoding": "wav/pcm",
115+
"bit_depth": 16,
116+
"sample_rate": 16000,
117+
"channels": 1,
118+
"language_config": { "languages": ["en"], "code_switching": false },
119+
"messages_config": {
120+
"receive_partial_transcripts": true,
121+
"receive_final_transcripts": true
122+
},
123+
"endpointing": 0.8,
124+
"maximum_duration_without_endpointing": 30,
125+
"realtime_processing": {
126+
"custom_vocabulary": false,
127+
"custom_spelling": false
128+
}
129+
}
130+
```
131+
132+
See the full schema in the [live init reference](/api-reference/v2/live/init).
133+
134+
### Start the transcription session
135+
136+
Open a live transcription session using your configuration. The flow is the same as with AssemblyAI: establish the WebSocket and get ready to stream audio.
137+
138+
_For AssemblyAI :_
139+
140+
<CodeGroup>
141+
142+
```python Python
143+
from assemblyai.streaming.v3 import StreamingParameters
144+
145+
assemblyClient.connect(
146+
StreamingParameters(
147+
sample_rate=16000,
148+
format_turns=True,
149+
)
150+
)
151+
```
152+
153+
```typescript Typescript
154+
const assemblySession = assemblyClient.streaming.transcriber({
155+
sampleRate: 16_000,
156+
formatTurns: true,
157+
});
158+
159+
await assemblySession.connect();
160+
```
161+
162+
</CodeGroup>
163+
164+
_For Gladia :_
165+
166+
<CodeGroup>
167+
168+
```python Python
169+
gladia_session = gladia_client.live_v2().start_session(gladia_config)
170+
```
171+
172+
```typescript Typescript
173+
const gladiaSession = gladiaClient.liveV2().startSession(gladiaConfig);
174+
```
175+
176+
</CodeGroup>
177+
178+
### Send audio chunks
179+
180+
Stream audio frames to the session as they are produced. Both SDKs accept small chunks continuously—keep your existing chunking logic.
181+
182+
_For AssemblyAI :_
183+
184+
<CodeGroup>
185+
186+
```python Python
187+
assemblyClient.stream(audio_chunk)
188+
```
189+
190+
```typescript Typescript
191+
assemblySession.stream(audioChunk);
192+
```
193+
194+
</CodeGroup>
195+
196+
_For Gladia :_
197+
198+
<CodeGroup>
199+
200+
```python Python
201+
gladia_session.send_audio(audio_chunk)
202+
```
203+
204+
```typescript Typescript
205+
gladiaSession.sendAudio(audioChunk);
206+
```
207+
208+
</CodeGroup>
209+
210+
### Read transcription messages
211+
212+
After audio is flowing, subscribe to transcript and lifecycle events. The mapping below shows how to translate AssemblyAI listeners to Gladia in a single place.
213+
214+
Event mapping from AssemblyAI to Gladia:
215+
216+
- `Transcript` → listen to Gladia `message` and branch on `message.data.is_final` to separate partial vs final results.
217+
- `Open`/`Close`/`Error` → map to Gladia `started`/`ended`/`error`.
218+
219+
In practice, subscribe once to `message` and use the `is_final` flag instead of wiring separate listeners—less boilerplate, same control. To receive partials, enable `messages_config.receive_partial_transcripts: true` in your init config.
220+
221+
_For AssemblyAI :_
222+
223+
<CodeGroup>
224+
225+
```python Python
226+
from typing import Type
227+
228+
from assemblyai.streaming.v3 import (
229+
BeginEvent,
230+
StreamingClient,
231+
StreamingError,
232+
StreamingEvents,
233+
StreamingSessionParameters,
234+
TerminationEvent,
235+
TurnEvent,
236+
)
237+
238+
239+
def on_begin(self: Type[StreamingClient], event: BeginEvent):
240+
print(f"Session started: {event.id}")
241+
242+
243+
def on_turn(self: Type[StreamingClient], event: TurnEvent):
244+
print(f"{event.transcript} ({event.end_of_turn})")
245+
246+
if event.end_of_turn and not event.turn_is_formatted:
247+
params = StreamingSessionParameters(
248+
format_turns=True,
249+
)
250+
self.set_params(params)
251+
252+
253+
def on_terminated(self: Type[StreamingClient], event: TerminationEvent):
254+
print(
255+
f"Session terminated: {event.audio_duration_seconds} seconds of audio processed"
256+
)
257+
258+
259+
def on_error(self: Type[StreamingClient], error: StreamingError):
260+
print(f"Error occurred: {error}")
261+
262+
263+
client.on(StreamingEvents.Begin, on_begin)
264+
client.on(StreamingEvents.Turn, on_turn)
265+
client.on(StreamingEvents.Termination, on_terminated)
266+
client.on(StreamingEvents.Error, on_error)
267+
```
268+
269+
```typescript Typescript
270+
assemblySession.on("open", ({ id }) => {
271+
console.log(`Session opened with ID: ${id}`);
272+
});
273+
274+
assemblySession.on("error", (error) => {
275+
console.error("Error:", error);
276+
});
277+
278+
assemblySession.on("close", (code, reason) =>
279+
console.log("Session closed:", code, reason),
280+
);
281+
282+
assemblySession.on("turn", (turn) => {
283+
if (!turn.transcript) {
284+
return;
285+
}
286+
287+
console.log("Turn:", turn.transcript);
288+
});
289+
```
290+
291+
</CodeGroup>
292+
293+
_For Gladia :_
294+
295+
<CodeGroup>
296+
297+
```python Python
298+
from gladiaio_sdk import (
299+
LiveV2WebSocketMessage,
300+
LiveV2InitResponse,
301+
LiveV2EndedMessage,
302+
)
303+
304+
@live_session.on("message")
305+
def on_message(message: LiveV2WebSocketMessage):
306+
# Partial and final transcripts are delivered here
307+
# filter them with message.data.is_final field
308+
print(message)
309+
310+
@live_session.once("started")
311+
def on_started(_response: LiveV2InitResponse):
312+
print("Session started. Listening...")
313+
314+
@live_session.once("ended")
315+
def on_ended(_ended: LiveV2EndedMessage):
316+
print("Session ended.")
317+
318+
@live_session.on("error")
319+
def on_error(error: Exception):
320+
print(f"Error: {error}")
321+
```
322+
323+
```typescript Typescript
324+
gladiaSession.on("message", (message) => {
325+
// Partial and final transcripts are delivered here
326+
// filter them with message.data.is_final field
327+
console.log(message);
328+
});
329+
330+
gladiaSession.on("started", (info) => {
331+
console.log("Start session", info);
332+
});
333+
334+
gladiaSession.on("ended", (info) => {
335+
console.log("End session", info);
336+
});
337+
338+
gladiaSession.on("error", (err) => {
339+
console.error("Error", err);
340+
});
341+
```
342+
343+
</CodeGroup>

docs.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,16 @@
110110
{
111111
"group": "Migrations",
112112
"pages": [
113-
"chapters/live-stt/migration-from-v1",
114-
"chapters/pre-recorded-stt/migration-from-v1",
115-
"chapters/migrations/from-deepgram"
113+
"chapters/migrations/from-deepgram",
114+
"chapters/migrations/from-assembly",
115+
{
116+
"group": "Gladia V2",
117+
"expanded": true,
118+
"pages": [
119+
"chapters/live-stt/migration-from-v1",
120+
"chapters/pre-recorded-stt/migration-from-v1"
121+
]
122+
}
116123
]
117124
}
118125
]

0 commit comments

Comments
 (0)