STT WebSocket
Real-time Speech-to-Text transcription via WebSocket streaming with support for 39 languages (including code-switched Indic+English) and telephony integration. Powered by 60db STT v01 (a non-hallucinating, multi-backend speech recognition stack).Endpoint
Authentication
Query parameter authentication: Examples:The WebSocket connection checks workspace wallet balance before starting a session. If the workspace has insufficient credits, the connection is closed with a
1008 status code and an INSUFFICIENT_CREDITS error.Connection Details
| Property | Value |
|---|---|
| Protocol | WebSocket (RFC 6455) |
| Frame types | Binary (telephony) or Text/JSON (browser) |
| Ping/keepalive | Server sends WebSocket pings every 30s (timeout 10s) |
200 ok — safe for load-balancer health checks.
Session Lifecycle
context object on start, every utterance produces two transcription events sharing a sentence_id:
- First emit —
is_final: true, speech_final: false— fast dict-corrected text. Use for low-latency UI paint and barge-in. - Canonical —
is_final: true, speech_final: true— definitive LLM-refined answer. Always arrives.
context is omitted, every utterance produces a single transcription event with is_final: true, speech_final: true (no first emit). Simple consumers can gate exclusively on speech_final: true regardless of whether refinement is on.
Client → Server Messages
start — Begin session
Sent once after connection is established. Must be sent before any audio.
audio — JSON audio chunk (browser mode)
Binary frame — raw μ-law audio (telephony mode)
Send a raw WebSocket binary frame with μ-law bytes, no JSON wrapper. The server auto-detects this as telephony mode on the first binary frame.config — Change language mid-session
languages and continuous_mode are optional; include only fields you want to change.
Send "languages": null to revert to auto-detect.
stop — End session
session_stopped, then closes.
test — Ping / latency check
test_response with the same timestamp for round-trip measurement.
Server → Client Messages
connecting — Authentication in progress
connection_established — Authentication successful
Service name:
"stt"Your user ID
Available credits
Workspace name
connected — Proxy wired to upstream STT server
Sent by the backend proxy after it has opened the upstream connection and attached its client-message listener. After this point, client messages are no longer dropped.
session_started — start message processed, audio is now accepted
Sent by the upstream STT server after a start message is received and validated. It is safe to begin sending audio frames immediately after this event.
speech_started — VAD detected voice activity
transcription — Transcription result
All results (interim and final) share the same transcription type — differentiate with flags.
Final result (is_final=true, speech_final=true):
text="", is_final=true, speech_final=true):
Sent when audio was detected but transcription was rejected (silence, hallucination, low confidence, wrong language).
Client should reset its state on this message and not treat it as an error.
is_final=false, speech_final=false) — only sent when interim_results_frequency is set:
is_final=true, speech_final=true will follow.
Response Fields:
Transcribed text. Empty string = speech-end-no-result signal.
0.0–1.0. Telephony typically 0.35–0.75; browser 0.55–0.95.
Detected language code e.g.
"en".Uppercase language code (e.g.
"EN") in the WS shape. Note: REST /stt returns the full English name ("English") here — WS preserves the legacy uppercase-code shape for client compatibility.true = end of speech reached. May still be followed by a canonical upgrade if LLM refinement is active.true = canonical answer, will not be revised. When LLM refinement is on, one is_final: true, speech_final: false event is followed by one is_final: true, speech_final: true. When refinement is off, every final is speech_final: true. See Canonical-answer semantics.true for interim results only.Monotonically increasing counter per session.
Duration (seconds) of the audio segment transcribed.
Seconds from processing start to result ready (excludes queue time).
Word-level timestamps
[{word, start, end, confidence}]. Note: the field name is confidence, not probability (60db STT convention — different from legacy Whisper docs). Present on finals; empty on interims.List of
[{speaker, start, end}] diarization turns when config.diarize=true. Omitted or null otherwise. Raw speaker IDs look like SPEAKER_00, SPEAKER_01; clients typically re-label these as “Speaker 1”, “Speaker 2” in order of first appearance."speech_end_no_result" on empty-speech-final. Omitted on ordinary finals.Canonical-answer semantics: speech_final
is_final and speech_final are NOT identical when LLM refinement is active — they split into two distinct meanings:
is_final | speech_final | Meaning |
|---|---|---|
false | false | Interim partial — text may still change as more audio arrives. |
true | false | End-of-speech reached, dict-corrected text. The LLM is still processing. A follow-up event with speech_final: true will arrive shortly with the canonical text. Only emitted when refinement is active for this utterance. |
true | true | Canonical answer. Definitive, will not be revised. LLM-refined text when context was supplied, otherwise the original ASR text. |
sentence_id is echoed across both phases so clients can reconcile.
Canonical event example (after LLM refinement):
- Exactly one canonical event per utterance. When refinement is on, you get two
transcriptionevents per utterance (first emit + canonical). When refinement is off, you get one (speech_final: true). Never zero, never three. - Same
sentence_idacross both phases. Reconcile on that key. - The canonical always arrives. Consumers waiting on
speech_final: truenever hang. sentence_idordering is preserved per session, but canonicals are NOT guaranteed to arrive insentence_idorder when LLM is on — two utterances finalizing close in time may complete refinement out of order. Key onsentence_id, not arrival order.words[]corresponds to the original ASR output on both phases — the LLM does not realign tokens. Usewords[]for word-level timing,textfor display.
speech_final: false) to NLU immediately for fast intent dispatch — don’t wait for canonical. If your NLU benefits from proper-noun accuracy (name-spelling slots, drug-name lookup), run a second-pass call on the canonical (speech_final: true) text and reconcile on sentence_id.
Legacy
refined event. Earlier builds emitted a separate refined event ~400 ms after the final instead of a second transcription. The 60db /ws/stt proxy transparently handles both shapes — if you’re still seeing refined events in the wire trace, upstream workers haven’t been restarted onto the two-phase build yet. New client code should target the two-phase flow only; refined is accepted but deprecated.language_changed — After config message changes language
mode_changed — After config message changes continuous_mode
session_stopped — After stop is processed
error — Processing error
test_response — Reply to test ping
Complete Example
Audio Requirements
| Property | Telephony (μ-law) | Browser (PCM) |
|---|---|---|
| Encoding | mulaw (8-bit) | linear (16-bit) |
| Sample Rate | 8000 Hz | 16000, 24000, 44100, 48000 Hz |
| Chunk Size | 480 bytes (60ms) | 960-1920 bytes (60-120ms) |
| Channels | Mono (1 channel) | Mono (1 channel) |
Supported Languages
39 transcription languages total (25 European, 13 Indic with Hinglish code-switching, and Arabic MSA). Fetch the full catalog fromGET /stt/languages.
| Code | Language | Code | Language |
|---|---|---|---|
en | English | hi | Hindi |
es | Spanish | bn | Bengali |
fr | French | mr | Marathi |
de | German | pa | Punjabi |
it | Italian | gu | Gujarati |
pt | Portuguese | ta | Tamil |
nl | Dutch | te | Telugu |
pl | Polish | kn | Kannada |
ru | Russian | ml | Malayalam |
uk | Ukrainian | or | Odia |
cs | Czech | as | Assamese |
sv | Swedish | ne | Nepali |
ar | Arabic (MSA) | sa | Sanskrit |
hi+en, bn+en, mr+en, pa+en, gu+en, or+en, as+en, ne+en, te+en, kn+en, ta+en, ml+en — collapses to the fast path when both languages share the same pipeline.
Not supported (explicit rejection): ur, ja, ko, zh, th, vi, id, tl, sw, tr, fa, he. These return an unsupported_language error — there is no silent aliasing. Arabic dialect tags (ar-eg, ar-lv, ar-gu, ar-ma) return dialect_not_supported — pass ar for best-effort MSA transcription of dialectal audio.
Limitations and Best Practices
Handshake ordering (most common mistake) Do not sendstart in ws.onopen. Wait for the proxy’s connection_established message first — it marks the point at which the proxy has attached its client-message listener. Likewise, wait for session_started before sending audio frames, otherwise the upstream server returns unknown message type: audio.
utterance_end_ms clamp
Values below 300 ms are silently clamped to 300 ms. Sub-300 ms would fragment utterances and cause the non-hallucinating backends to drop short segments.
Language count
Max 5 languages per session. Cross-backend multi-language (e.g. ["en","ar"]) runs per-utterance LID which adds ~20–50 ms per utterance. Same-backend multi-language (e.g. ["en","hi"]) collapses to a single backend’s fast path with zero LID overhead — use this whenever possible.
Telephony confidence
8 kHz μ-law → 16 kHz resampling reduces backend confidence by ~0.10–0.15 compared to native wideband input. Use a client-side threshold of 0.35 for telephony vs 0.55 for browser.
Buffer limits
- Pre-speech ring buffer: 1.0 s (captures first word before VAD fires)
- Minimum coalesce before VAD: 160 ms (μ-law 1280 bytes, linear
sample_rate × 2 × 160 / 1000bytes) - Maximum utterance duration: 30 s (anything longer force-finalizes)
- Speech start: Silero probability >
STT_VAD_THRESHOLD(default 0.5, server-configurable) - Silence → utterance end:
utterance_end_msof consecutive sub-threshold audio - No separate continuation threshold
no_speech_prob — the CTC/RNN-T topology emits blank tokens on non-speech. Hallucination guard is a word-rate sanity check (> 5 words/second → rejected).
Diarization
diarize=true requires HF_TOKEN on the server plus gated model approval for pyannote/speaker-diarization-3.1. Without both, the request silently falls back to a deterministic mock. Check session_started.diarize to confirm the request was accepted.
Pricing
- Rate: $0.00000833 per second
- Minimum: $0.01 per session
- Billing: Per second of audio processed
Error Codes
| Code | Description |
|---|---|
| 1008 | Authentication failed |
| 1008 | Insufficient credits |
| 1011 | Internal server error |
| 1006 | Connection lost |
Testing
Related
- TTS WebSocket - Text-to-Speech endpoint
- WebSocket API Reference - Complete documentation
- Voices API - Get available voices