Architecture

VoxGraph is a single FastAPI process exposing one WebSocket endpoint. All real-time work happens over that connection — binary PCM in, binary PCM + JSON status events out.

Pipeline overview

Client

WebSocket

STT

Utterance

Memory

LLM

TTS

JSON events

PCM 24 kHz

Key modules

ModuleRole
voxgraph/api/audio.pyWebSocket handler, Deepgram STT stream, debounce, response pipeline
voxgraph/api/config.pyHosted setup: /config/health, /config/test, /config/apply
voxgraph/providers/llm.pyGemini + Ollama streaming, system prompt, chat history
voxgraph/providers/tts.pyDeepgram Aura TTS, phrase chunking, PCM streaming
voxgraph/pipeline/response.pyOrchestrates STT → memory → LLM → TTS for each utterance
voxgraph/voice/utterance.pyDebouncing, barge-in, pending utterance staging
voxgraph/memory/store.pySQLite semantic facts + episodic turns
voxgraph/voice/intents.pyFast-path replies without LLM (names, greetings)
voxgraph/transport/outbound.pySerialized WebSocket sends (safe concurrent send/receive)
scripts/live_mic_client.pyReference client: continuous mic + speaker playback

Concurrency model

  • Main loop: receive_bytes() from client → forward to Deepgram
  • Deepgram callbacks: append transcripts, schedule debounced LLM task
  • LLM/TTS runs in asyncio task; outbound audio via WsOutbound queue
  • Keepalive pings Deepgram during long LLM+TTS so the STT stream stays open
  • Barge-in cancels in-flight TTS when new speech is detected

Design goals

  • Hackable — small modules under voxgraph/, clear extension points
  • Local-first — Ollama + Deepgram without mandatory cloud LLM
  • Conversation-aware — episodic turns fed back as Ollama chat messages
  • Hostable — Docker + Render; runtime config API for online demos