Follow along with the runnable example. This guide walks through the diarized ambient example in
corti-examples — bootstrap your build from it or use it as reference./streams, the server attributes speech to distinct speakers. Because each speaker’s segments are finalized independently, transcript messages do not arrive in chronological order — and each message carries an array of segments, not a single one. Your client is responsible for ordering them and grouping by speaker before rendering.
This guide shows the client handling using the Ambient Web Component. It’s the ambient counterpart to dictation text insertion — but the concern here is purely ordering, not interim-vs-final reconciliation.
For the ordering rules — the
time/speakerId/channel fields and why arrival order is unreliable — see Diarized Transcript Handling. This page focuses on wiring them into your app.Configure a diarized stream
EnableisDiarization to separate speakers within a single mono stream. For fixed per-channel roles instead, use isMultichannel with participants — the two are mutually exclusive. See the diarized ambient example in corti-examples for the full stream configuration.
Merge each message in order
Eachtranscript event carries an array of final segments. Merge every message into a running list keyed by segment identity, and keep it sorted by time.start (tie-break time.end) — never append in arrival order.
JavaScript
mergeDiarizedSegments from your transcript event handler, passing e.detail?.data (the segment array) as incoming.
Only final segments are sent on
/streams (there are no interim results), so there is no interim-vs-final dedup to do — just ordering and de-duplication by segment identity.Group by speaker
To render speaker-labelled blocks, collapse the ordered list into consecutive runs by speaker — so one speaker’s words are never interleaved into another’s.JavaScript
speakerId and participant.channel are independent — diarization separates speakers within a stream, while the channel reflects audio routing. Don’t assume a fixed mapping between them, and remember speakerId is -1 when diarization is off.Next steps
Diarized Transcript Handling
The ordering rules and segment fields behind this integration.
Ambient Web Component
The drop-in component for real-time multi-speaker ambient streaming.
Example code
The complete, runnable diarized ambient example in
corti-examples.Please contact us for help or questions.