Skip to content
Monologue
Esc
navigateopen⌘Jpreview
On this page

Realtime streaming

Stream PCM audio over WebSocket and receive partial and final results.

Connect to:

wss://go.monologue.to/v1/enterprise/streaming

Use the monologue.dictate.realtime.v1 protocol. Realtime sessions accept mono 16 kHz signed 16-bit little-endian PCM (pcm_s16le) and support smart or transcription as the source.

Authenticate

Non-browser clients can send X-API-Key or an Authorization: Bearer client token during the WebSocket handshake.

Browsers cannot set those headers. Mint an origin-bound client token, encode it as unpadded base64url, and send it as a credential subprotocol:

const credential = btoa(clientToken).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");

const socket = new WebSocket("wss://go.monologue.to/v1/enterprise/streaming", [
  "monologue.dictate.realtime.v1",
  `monologue.enterprise.bearer.${credential}`,
]);

Start the session

Send session.start before any audio. transcription_id must be nonblank.

{
  "type": "session.start",
  "protocol_version": 1,
  "transcription_id": "0198b68f-c6e1-7891-a341-803eb8fe421f",
  "source": "smart",
  "languages": ["en"],
  "platform": "web",
  "app_version": "1.0.0",
  "audio": {
    "encoding": "pcm_s16le",
    "sample_rate_hz": 16000,
    "channels": 1
  },
  "dictionary": "Monologue, Avery",
  "context": "<app_name>Slack</app_name>"
}

Wait for session.ready, then send raw PCM bytes as binary WebSocket frames. Do not wrap them in JSON or base64. When audio is complete, send:

{
  "type": "input.commit",
  "extra_instructions": "Write a concise Slack message."
}

Optional persistence

Realtime sessions are metadata-only by default. To intentionally persist the session for diagnostics or feedback, add "store": true to the initial session.start message:

{
  "type": "session.start",
  "protocol_version": 1,
  "transcription_id": "0198b68f-c6e1-7891-a341-803eb8fe421f",
  "source": "smart",
  "store": true,
  "audio": {
    "encoding": "pcm_s16le",
    "sample_rate_hz": 16000,
    "channels": 1
  }
}

This stores the streamed audio, raw and final transcripts, context, dictionary, and extra instructions associated with the session. Streamed PCM is retained as a mono 16 kHz WAV file. Set store only when your product and end user have intentionally opted into content persistence. The setting cannot be changed after the session starts.

Use the same transcription_id when submitting feedback so Monologue can correlate the feedback with the stored session data.

Server events

Event Meaning
session.ready The server is ready for audio.
transcript.partial Unstable partial text for live UI.
transcript.segment A stable segment and accumulated text.
transcript.final Final raw transcript after commit.
result.final Final text, raw_text, output mode, and timing data.
session.completed The session finished successfully or was cancelled.
session.error The session failed; inspect code and retry_via_async.

You may send context.update before commit to replace context, dictionary, or extra instructions. Send session.cancel to stop without a final result. Audio frames are rejected after input.commit.

Was this page helpful?