Realtime transcription
Send audio as it becomes available and receive partial transcripts while the speaker talks. At the end of each utterance, receive a final transcript. One connection can transcribe multiple utterances.
For a runnable example, follow the STT quickstart. Free STT endpoints have endpoint-specific concurrent session and daily request limits.
Connect and configure
Connect from your backend using your API key:
Wait for session.created, then send your session configuration:
Wait for session.configured before sending audio. It returns the applied settings and defaults in session, with duration and idle limits in session.limits. The configuration is fixed for this connection.
Session arguments
These fields belong inside session in the initial session.configure:
The API reference lists all accepted language codes, VAD fields, and validation limits.
Send audio
Use 16 kHz, signed 16-bit little-endian PCM, mono, without a WAV header. Encode each chunk as base64 and send it in an input_audio_buffer.append JSON message:
For example, 100 ms of audio is 3,200 bytes before base64 encoding. Each chunk must contain whole two-byte samples, and the complete JSON message must fit within 128 KiB.
Send and receive in Python
This complete example sends audio and reads events concurrently. It keeps receiving after each final result, so automatic boundaries and multiple utterances work on the same connection. At the end of the audio source, it commits remaining audio and waits for all acknowledged utterances to finish.
Use Python 3.11+, set NARI_API_KEY, and place the quickstart sample hello.pcm beside stt_stream.py.
pcm_file paces a recording in 100 ms chunks. For live input, pass an async iterator that yields PCM bytes as they arrive; no extra pacing is needed. Yield None when your application wants a manual commit. These are conventions of this example function; the actual WebSocket messages are append and commit.
The on_event callback receives every server event. The result-handling and VAD examples build on this module. Keep callbacks short so receiving is not blocked.
Read the results
Partial transcripts may change as more audio arrives, including words returned earlier. After an utterance ends, the server returns a completed transcript that replaces all partial text for that item_id.
A partial result:
The completed result for the same item_id:
Transcripts and turn detection explains how to update text, finalize utterances, and reuse the connection. For timeouts and reconnecting, use WebSocket failures.