Realtime transcription
The live transcription WebSocket protocol, with every message, error and close code.
Open a WebSocket, send raw audio as binary frames, and receive JSON messages with words as they're recognised. Authenticate the handshake with your API key, exactly like any other endpoint:
wss://api.voice.wistfare.com/v1/stt/stream?model=wistfare-stt-v3-beta&language=auto&latency=balanced
Authorization: Bearer wv_sk_…The key needs all permission; a bad key is refused with HTTP 403 before the socket opens (see Close codes). The SDKs wrap this protocol; this page is for using the socket directly.
Query parameters
| Parameter | Default | Description |
|---|---|---|
model | wistfare-stt-v3-beta | wistfare-stt-v3-beta, wistfare-stt-v2-beta or wistfare-stt-v1-beta. |
language | auto | auto, rw, en, fr, sw; with v3 also lg and rn. |
latency v3 | balanced | fast (≈ 0.32 s), balanced (≈ 0.56 s) or accurate (≈ 1.12 s). |
boost v3 | — | Key terms, comma-separated and URL-encoded. At most 100, each up to 100 characters. |
punctuation v3 | 1 | 0 returns lower-case words without punctuation. |
token | — | Optional. A single-use wv_st_… token for client-side streaming, used instead of the Authorization header. |
Build the URL with an encoder so key terms with spaces or accents survive:
const params = new URLSearchParams({
model: 'wistfare-stt-v3-beta',
language: 'auto',
latency: 'balanced',
boost: ['Nyabugogo', 'MTN MoMo', 'Irembo'].join(','),
});
const url = `wss://api.voice.wistfare.com/v1/stt/stream?${params}`;Client messages
| Frame | Content |
|---|---|
| Binary | Raw PCM audio: 16-bit signed little-endian, mono, 24,000 Hz, no header. Any even number of bytes; about 320 ms (15,360 bytes) per frame is a good default. |
| Text | {"type": "end"} when the speaker is done. The server finishes the last words, sends final and closes the socket. |
Audio sent before ready is buffered, not lost.
Server messages
Every server message is a JSON text frame with a type. Ignore types and fields you don't recognise; new fields can be added at any time.
| Type | When | Key fields |
|---|---|---|
ready | The model is up and listening. | sample_rate, frame_ms, model, max_seconds |
words | Words completed, the partial word changed, or a heartbeat about once a second while audio flows. | final, partial, seconds, language |
final | After your end, or right after an error. | text, words, segments, language, transcription_id, cost_cents, audio_seconds |
error | Something stopped the session. A final message with the transcript so far follows, then the socket closes. | code, message, request_id |
status | The service is recovering from an interruption. | state, message |
ready
{ "type": "ready", "sample_rate": 24000, "frame_ms": 80, "model": "wistfare-stt-v3-beta", "max_seconds": 900, "max_wall_seconds": 1200, "idle_timeout_seconds": 30, "latency": "balanced", "punctuation": true }max_seconds is the audio limit, max_wall_seconds the wall-clock limit and idle_timeout_seconds how long the session waits without audio. See Limits and billing.
The first session after a quiet period can take a little longer to become ready while the model warms up.
words
{
"type": "words",
"final": [
{ "word": "Muraho", "start": 0.24, "speaker": null, "language": "rw" },
{ "word": "neza,", "start": 0.72, "speaker": null, "language": "rw" }
],
"partial": "murakaza",
"seconds": 1.6,
"language": "rw"
}| Field | Description |
|---|---|
final | Words completed since the previous message. Append them. Each has word, start (seconds), speaker (always null on live sessions) and, on v3, language. |
partial | The word being recognised right now. It can still change: replace it on every message. |
seconds | Audio received so far, in seconds. |
language | v3: the most recently detected language. |
replace | Only after a recovery (see status): final then holds every word so far, so replace your list instead of appending. |
final
{
"type": "final",
"text": "Muraho neza, murakaza neza kuri Wistfare. Let's look at the numbers.",
"words": [
{ "word": "Muraho", "start": 0.24, "end": 0.72, "speaker": null, "language": "rw" }
],
"segments": [
{ "start": 0.24, "end": 3.1, "speaker": null, "language": "rw", "text": "Muraho neza, murakaza neza kuri Wistfare." },
{ "start": 3.4, "end": 5.2, "speaker": null, "language": "en", "text": "Let's look at the numbers." }
],
"language": "rw",
"seconds": 5.6,
"audio_seconds": 5.6,
"transcription_id": "tr_51c7d0a9e2b84f13c6aa",
"cost_cents": 2
}words (shortened above) and segments have the same shape as in POST /v1/stt. language is the session's main language. The transcript is stored: fetch it again with GET /v1/stt/transcriptions/{id}.
error
{ "type": "error", "code": "insufficient_credits", "message": "Your credit balance ran out, so the session was stopped." }| Code | Meaning |
|---|---|
unsupported_model / unsupported_language / unsupported_latency | An option isn't valid. Sent right before the socket closes with 4400. |
too_many_boost_terms / boost_term_too_long | More than 100 key terms, or a term over 100 characters (4400). |
token_mismatch | A token was used with a different model, language or latency than it was minted for (4400). |
read_only_key | The key can't transcribe (4403). |
insufficient_credits / budget_exceeded | No credits at the start (4402), or the next minute couldn't be reserved during the session. A mid-session failure ends the session gracefully with its transcript. |
concurrency_limit | The account already has its maximum of live sessions open (2 by default). Sent right before close code 4429. |
account_suspended | Spending is suspended on this account (4403). |
audio_limit / too_long | The session reached 15 minutes of audio, or a frame had an odd number of bytes. |
wall_clock_limit | The session was open for 20 minutes. |
audio_idle_timeout | No audio arrived for 30 seconds. |
busy | All live capacity is in use. Retry in a few seconds. |
model_unavailable / model_stalled / finish_timeout | The connection to the model failed and couldn't be recovered. |
Once a session has started, an error is always followed by a final message with the transcript so far (text, words, segments, transcription_id, cost_cents, audio_seconds): what was recognised is saved, and the error message states exactly what was charged. If the model connection failed, you're billed only for the audio up to the last committed word.
status
{ "type": "status", "state": "reconnecting", "message": "Reconnecting transcription. Your audio is still being recorded…" }state is reconnecting or recovering while the service reconnects to a model and catches up on buffered audio, then listening when it's live again. Keep sending audio. The next words message has replace: true.
Close codes
| Code | Meaning |
|---|---|
1000 | Normal close after final (or after an error message). |
4403 | The API key is read-only, or the account is suspended (account_suspended). |
4400 | Invalid options. The preceding error message has the exact code. |
4402 | Insufficient credits, or the project's budget is reached. |
4429 | Too many live sessions open on the account (concurrency_limit). Retry when one ends. |
A bad key never opens a socket. A missing, invalid or revoked API key, or an unknown, expired or already-used token, is refused during the handshake with HTTP 403. There's no close code and no error message: browsers only report a failed connection (onerror, then onclose with code 1006), and libraries such as websockets and ws raise a handshake error with status 403. The SDKs raise AuthenticationError.
Limits and billing
| Limit | Default | Error |
|---|---|---|
| Audio per session | 15 minutes (max_seconds) | audio_limit |
| Wall-clock time per session | 20 minutes (max_wall_seconds) | wall_clock_limit |
| Time without audio | 30 seconds (idle_timeout_seconds) | audio_idle_timeout |
| Concurrent sessions per account | 2 | concurrency_limit, close 4429 |
| Key terms | 100 | too_many_boost_terms, close 4400 |
Account limits can be raised on request.
Billing is per second of audio sent, at $0.012 per minute on every model, with a minimum of one minute (2¢) for a session that received audio, charged when the session ends, including when the client disconnects without end. Before connecting, one minute is reserved from your balance; before each further minute of audio, the next minute is reserved. A session that never received audio costs nothing.
Examples
Stream a file in real time with plain WebSocket libraries (no SDK):
import asyncio
import json
import os
import websockets # pip install "websockets>=14"
URL = (
"wss://api.voice.wistfare.com/v1/stt/stream"
"?model=wistfare-stt-v3-beta&language=auto&latency=balanced"
)
CHUNK = 7680 * 2 # 320 ms of 24 kHz, 16-bit mono audio
async def main():
headers = {"Authorization": f"Bearer {os.environ['WISTFARE_API_KEY']}"}
async with websockets.connect(URL, additional_headers=headers) as ws:
async def send_audio():
with open("call-24k-mono.pcm", "rb") as f:
while chunk := f.read(CHUNK):
await ws.send(chunk)
await asyncio.sleep(0.32) # real-time pacing, like a microphone
await ws.send(json.dumps({"type": "end"}))
sender = asyncio.create_task(send_audio())
words = []
async for raw in ws:
msg = json.loads(raw)
if msg["type"] == "words":
fresh = [w["word"] for w in msg["final"]]
words = fresh if msg.get("replace") else words + fresh
print("\r" + " ".join(words[-12:]), msg["partial"], end="", flush=True)
elif msg["type"] == "final":
print(f"\n\n{msg['text']}\n{msg['cost_cents']}¢ · {msg['transcription_id']}")
elif msg["type"] == "error":
print(f"\nerror {msg['code']}: {msg['message']}")
sender.cancel()
asyncio.run(main())To prepare call-24k-mono.pcm from any recording: ffmpeg -i call.mp3 -ac 1 -ar 24000 -f s16le call-24k-mono.pcm.