Skip to main content

Architecture

The voice pipeline runs entirely server-side. Your device streams Opus-encoded audio frames over a single WebRTC connection; the server processes speech, inference, and synthesis in a unified streaming loop. You never need to call a transcription or TTS API yourself. Key characteristics:
  • Codec — Opus, 48 kHz, mono
  • VAD — server-side, 600 ms silence threshold
  • Barge-in — the user can interrupt mid-response; the AI stops immediately
  • Latency — typically 80–150 ms from end of speech to first audio frame back

Gemini Live architecture

Voice sessions use Gemini Live — a single bidirectional WebSocket between the Humain server and Google’s Gemini model that carries compressed audio in both directions. This replaces the previous STT → LLM → TTS chain with a single model that handles all three stages natively.
Gemini Live supports 90+ languages natively — you do not need to configure separate STT or TTS voices per language. Set preferred_language on the session open request and the model speaks that language automatically. See Language support.

Connection sequence

agent_url is the base URL for both WebRTC signalling calls and end — it may differ from the host that served POST /v1/sessions. ice_servers (TURN/STUN credentials) is only present in the response when TURN relay is configured for your workspace; fall back to a public STUN server when it’s absent, as shown below.

Browser integration

VAD and barge-in behaviour

You do not need to manage push-to-talk. The server detects end-of-utterance server-side:
  • VAD threshold — 600 ms of silence triggers end-of-utterance detection.
  • Barge-in — if the AI is speaking and the user starts talking, the server detects the interruption and stops the TTS stream immediately. The user’s speech is processed as a new turn.
There is no API to configure the VAD threshold per session — it is set globally per kiosk in the admin panel under Kiosk → Voice settings → VAD sensitivity.

Advanced topics

In NAT-heavy environments (cellular networks, corporate firewalls) STUN alone may not establish a peer connection. If your workspace has TURN configured server-side, the session-open response includes an ice_servers array with time-limited credentials — pass it straight to RTCPeerConnection as shown in the example above:
TURN relay itself is configured per-deployment on the server side (contact your Humain workspace admin, or see the self-hosted coturn setup in kiosk-infra if you run your own cluster) — clients don’t provision or hold long-lived TURN credentials themselves.
For embedded Linux devices or server-side Go/Python code that speaks WebRTC:
  • Go — pion/webrtc — the same library Humain uses internally.
  • Python — aiortc — asyncio-based, supports Linux ARM (Raspberry Pi, Jetson Nano).
  • Rust — webrtc-rs
The SDP exchange and ICE flow are identical — only the peer connection API differs.
Listen to pc.onconnectionstatechange to surface connection issues to the user: