Skip to main content
Telephony providers commonly send 8 kHz mono audio encoded as mu-law or A-law. Gradium supports those formats directly for STT and can produce telephony-friendly TTS output.

STT WebSocket Setup

Then send base64-encoded audio payloads:

TTS WebSocket Setup

The audio messages contain base64-encoded mu-law chunks that can be forwarded to a telephony media stream.

Chunk Size Guidance

Many telephony media streams send 20 ms frames. Gradium accepts small chunks, but batching to roughly 80 ms can reduce message overhead while keeping latency low:

Bridge Checklist

  • Preserve the provider’s stream/session ID in your own logs.
  • Use one Gradium STT session per caller audio stream.
  • Set input_format to the actual bytes you forward.
  • For TTS, request an output format your provider can play directly.
  • Use STT step messages or your provider’s VAD to decide when to send the user’s turn to an agent.
  • Close the WebSocket and start a new session if the call leg changes format.

Speech-to-Text WebSocket

Real-time transcription with VAD and flush.

Text-to-Speech WebSocket

Stream generated audio back to your telephony bridge.