Skip to main content

STT WebSocket API

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).

🚀 Quick Start (Copy & Paste)

That’s it! You’ll see:
  • ✅ Authenticated
  • ✅ Ready! Send audio now
  • 📝 Hello world (transcribed text)
  • ✅ Complete! Cost: $0.000043

📖 How It Works (5 Simple Steps)

  1. Connect with your API key
  2. Send { type: "start", ... } to begin session
  3. Stream audio data (binary chunks)
  4. Receive text transcriptions in real-time
  5. Stop with { type: "stop" } when done

Endpoint

Authentication

Query parameter authentication: Example:

Connection Details

Session Lifecycle

Two-phase finals (context-gated LLM refinement). When you supply a context object on start, every utterance produces two transcription events sharing a sentence_id:
  1. First emitis_final: true, speech_final: false — fast dict-corrected text. Use for low-latency UI paint and barge-in.
  2. Canonicalis_final: true, speech_final: true — definitive LLM-refined answer. Always arrives.
When 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 and ignore the rest — that gives them exactly one canonical event per utterance regardless of whether refinement is on.

Client → Server Messages

start — Begin session

Sent once after connection is established. Must be sent before any audio.
Parameters:

audio — JSON audio chunk (browser mode)

Fields:

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

Both languages and continuous_mode are optional; include only fields you want to change. Send "languages": null to revert to auto-detect.

stop — End session

Server processes any remaining audio buffer, sends session_stopped, then closes.

test — Ping / latency check

Server echoes test_response with the same timestamp for round-trip measurement.

Server → Client Messages

connecting — Authentication in progress

connection_established — Authentication successful

On STT these fields are top-level and the frame is tagged by type. Check msg.type === "connection_established"msg.connection_established is the TTS frame’s shape, and a client written against it will never start its STT session.
Fields:
string
Service name: "stt"
integer
Your user ID
number
Available credits
string
Workspace name

connected — After start message is processed

Expect two connected frames: the proxy’s own handshake (session_id plus a small server_info), then the upstream capability frame shown above. Neither means “audio is accepted” — wait for session_started. Keep any connected handler idempotent so audio capture does not start twice.

session_startedstart accepted, audio is now allowed

Send audio only after this event — earlier frames are answered with unknown message type: audio. llm_refinement: true confirms your context opened the refinement gate, so every utterance will arrive as a two-phase pair; false means one canonical event per utterance. languages is the resolved candidate list after normalization.

speech_started — VAD detected voice activity

Use this for barge-in: interrupt TTS playback when this arrives. Fired after 2 consecutive VAD-positive chunks (~64ms of confirmed speech).

transcription — Transcription result

All results (interim and final) share the same transcription type — differentiate with flags. Final result (is_final=true, speech_final=true):
Empty speech_final signal (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.
Interim result (is_final=false, speech_final=false) — only sent when interim_results_frequency is set:
Use interims only for barge-in word-count checks. Never send interim text to the LLM — a final with is_final=true, speech_final=true will follow. Response Fields:
string
Transcribed text. Empty string = speech-end-no-result signal.
number
0.0–1.0. Telephony typically 0.35–0.75; browser 0.55–0.95.
string
Detected language code e.g. "en".
string
Uppercase language code e.g. "EN".
boolean
true = end of speech reached. May still be followed by a canonical upgrade if LLM refinement is active.
boolean
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.
boolean
true for interim results only.
integer
Monotonically increasing counter per session.
number
Duration (seconds) of the audio segment transcribed.
number
Seconds from processing start to result ready (excludes queue time).
array
Word-level timestamps [{word, start, end, confidence}]. Note: the field is confidence, not probability. Present on finals; empty on interims.
integer
Timestamp (ms) of last word in the utterance.
string
Marker for utterances the consumer should skip. Omitted on ordinary finals. None of these are billed.
boolean
On canonical emits where refinement ran: true = text is the LLM-refined version, false = the LLM was skipped or failed and the fast first-emit text was promoted unchanged. llm_reason carries the why, llm_latency_ms the round-trip time. The canonical always arrives either way.
boolean
Added by the 60db proxy when the upstream rejected the utterance as a suspected hallucination but interim text was available — the proxy sends that text instead of an empty final, with tentative_reason: "hallucination_rejected". Safe to route on; flag it for review.

Canonical-answer semantics: speech_final

is_final and speech_final are NOT identical when LLM refinement is active — they split into two distinct meanings: The same sentence_id is echoed across both phases so clients can reconcile. Canonical event example (after LLM refinement):
Guarantees:
  • Exactly one canonical event per utterance. When refinement is on, you get two transcription events per utterance (first emit + canonical). When refinement is off, you get one (speech_final: true). Never zero, never three.
  • Same sentence_id across both phases. Reconcile on that key.
  • The canonical always arrives. Consumers waiting on speech_final: true never hang.
  • sentence_id ordering is preserved per session, but canonicals are NOT guaranteed to arrive in sentence_id order when LLM is on — two utterances finalizing close in time may complete refinement out of order. Key on sentence_id, not arrival order.
  • words[] corresponds to the original ASR output on both phases — the LLM does not realign tokens. Use words[] for word-level timing, text for display.
Recommended client patterns: Simplest — don’t care about the first-emit optimization:
With fast first-emit (UX-aware):
For voicebot NLU routing: feed the first-emit text (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

Only canonical finals (is_final: true and speech_final: true) with a duration are charged — first emits are previews, so turning on LLM refinement does not double your bill, and the four skip modes above cost nothing. client_estimated_seconds is a diagnostic estimate of what the client sent; never show it as a billed figure.

error — Processing error

test_response — Reply to test ping

Complete Example

    Audio Requirements

    Supported Languages

    39 languages total, backed by Parakeet-TDT (25 European), Vaani-FastConformer (13 Indic + Hinglish), and FC-Arabic (MSA). Fetch the full catalog from GET /stt/languages. Not supported (explicit rejection, no silent aliasing): ur, ja, ko, zh, th, vi, id, tl, sw, tr, fa, he. Arabic dialect tags (ar-eg, ar-lv, …) return dialect_not_supported — pass ar for best-effort MSA. Common languages:

    Pricing

    • Rate: $0.00000833 per second
    • Minimum: $0.01 per session
    • Billing: Per second of audio processed