@@ -170,17 +170,20 @@ async for chat_completion in stream:
170170
171171## Realtime transcription
172172
173- Stream audio over WebSocket and receive interim and final transcripts as the
174- audio plays. Requires the ` realtime ` extra:
173+ Transcribe live audio — a microphone, a phone call, a meeting — as it is being
174+ spoken. You stream PCM audio over a WebSocket and receive interim text within
175+ moments and a finalized transcript for each utterance. Requires the ` realtime `
176+ extra:
175177
176178``` sh
177179pip install " together[realtime]"
178180```
179181
180- ` client.realtime.transcription() ` is the recommended surface: an
181- auto-reconnecting session that buffers un-transcribed audio on the client and
182- replays it after a connection drop, so transient WebSocket failures don't lose
183- speech.
182+ Use ` client.realtime.transcription() ` : a session built for live sources. If
183+ the connection drops mid-conversation, the session holds on to the speech the
184+ server hadn't transcribed yet, reconnects automatically, and picks up where
185+ the transcript left off — words spoken during the outage still come back as
186+ text.
184187
185188``` python
186189from together import AsyncTogether
@@ -190,43 +193,50 @@ client = AsyncTogether()
190193
191194async with client.realtime.transcription(
192195 model = " openai/whisper-large-v3" ,
193- sample_rate = 16_000 , # validated against input_audio_format
196+ sample_rate = 16_000 ,
194197) as session:
195- await session.append(pcm_chunk) # 16 kHz mono s16le PCM, any chunk size
198+ # feed audio from your capture source as it arrives (any chunk size)
199+ await session.append(pcm_chunk) # 16 kHz mono 16-bit PCM
200+
196201 async for event in session:
197202 if isinstance (event, TranscriptDelta):
198- print (" interim:" , event.text)
203+ print (" interim:" , event.text) # updates while a phrase is spoken
199204 elif isinstance (event, TranscriptCompleted):
200- print (" final:" , event.text)
201- transcript = await session.flush()
202- ```
203-
204- Notes:
205-
206- - Audio must be PCM signed 16-bit little-endian; the default format is
207- ` pcm_s16le_16000 ` (16 kHz mono). Resample before appending.
208- - Server-side voice activity detection is on by default: final transcripts
209- arrive per detected utterance without explicit commits. Pass
210- ` turn_detection={"type": "none"} ` to segment manually with
211- ` await session.commit() ` .
212- - All server session parameters are supported: ` language ` , ` prompt ` ,
213- ` rolling_prompt ` , ` energy_gate_rms ` , turn-detection tuning via
214- ` turn_detection={...} ` (` threshold ` , ` min_silence_duration_ms ` ,
215- ` max_speech_duration_s ` , ` speech_pad_ms ` , Deepgram ` eot_* ` ), and
216- ` session_params={...} ` for engine-specific passthrough options.
217- - On retryable failures (network errors, server hiccups, 429/5xx handshakes)
218- the session reconnects with jittered exponential backoff and replays buffered
219- audio from ` max(head - max_replay_seconds, last transcribed position) ` , where
220- the transcribed position comes from the ` completed ` event's ` start + duration `
221- and ` buffer={"max_replay_seconds": 5.0} ` is the client-configurable cap
222- (` 0 ` resumes live with no replay; ` None ` replays the full untranscribed
223- window). Events produced from replayed audio carry ` replayed=True ` .
224- - Buffer gaps (audio dropped after outages exceeding the retention window) are
225- always surfaced as ` BufferGap ` events — never silent.
226- - The sync client (` Together().realtime.transcription(...) ` ) mirrors this API
227- and runs the session on a background thread — intended for low session
228- counts; use the async client for high-concurrency workloads.
229- - For full manual control (raw wire events, no retries), use
205+ print (" final:" , event.text) # one per finished utterance
206+
207+ transcript = await session.flush() # finalize whatever was said last
208+ ```
209+
210+ What to know before integrating:
211+
212+ - ** Audio in** : 16 kHz mono 16-bit PCM (` pcm_s16le_16000 ` ). Resample your
213+ source before appending — passing ` sample_rate= ` lets the SDK reject a
214+ mismatch loudly instead of incorrecly transcribing different sample rate .
215+ ` append() ` never blocks on network state, so it is safe to call from a capture loop.
216+ - ** Utterance boundaries** : detected server-side by default — final
217+ transcripts arrive on their own as the speaker pauses. To control
218+ segmentation yourself, pass ` turn_detection={"type": "none"} ` and call
219+ ` await session.commit() ` when each segment ends.
220+ - ** Tuning** : ` language ` , ` prompt ` , and turn-detection parameters
221+ (` min_silence_duration_ms ` , ` max_speech_duration_s ` , ...) are passed
222+ through to the service.
223+ - ** When the connection drops** : The session emits
224+ ` Reconnecting ` /` Reconnected ` events and tries to retry the connection.
225+ Transcripts recomputed from speech that was carried across the reconnect are marked
226+ ` replayed=True ` and may overlap text you already received; voice agents
227+ that act on each final can set ` buffer={"max_replay_seconds": 0} ` to
228+ resume live with no re-emission instead.
229+ - ** If audio is ever dropped** (an outage longer than the retention window),
230+ the session tells you with a ` BufferGap ` event.
231+ - ** If an endpoint fails for good** , calls raise ` RealtimeConnectionError ` .
232+ To keep a conversation alive across endpoint outages, run a failover ring —
233+ see [ ` examples/realtime_failover.py ` ] ( examples/realtime_failover.py ) :
234+ on failure, ` session.pending_audio() ` hands you the un-transcribed speech
235+ to seed a new session on another endpoint.
236+ - ** Sync applications** : ` Together().realtime.transcription(...) ` mirrors the
237+ async API on a background thread — good for a handful of sessions; use the
238+ async client for high concurrency.
239+ - ** Full manual control** (raw wire events, no automatic recovery):
230240 ` client.realtime.connect() ` .
231241
232242See [ ` examples/realtime_transcription.py ` ] ( examples/realtime_transcription.py )
0 commit comments