Berkay Orhan
WorkResearchExperienceAboutAskContact
Contact
← All projects

PROJECT / 2025

FastTalk

Real-Time Voice Stack

Real-time voice conversation stack with STT→LLM→TTS as standalone WebSocket microservices, plus a Next.js dashboard that streams audio and shows per-hop latency.

stack
Python · FastAPI · vLLM (OpenAI-compatible) · PydanticAI · Ollama · WebSockets · Faster-whisper · Docker · CUDA/MPS · Whisper VAD STT · Kokoro/Chatterbox TTS · Next.js 16 · React 19 · Tailwind v4 · AudioWorklet API · Radix UI · Recharts

Live site ↗Frontend ↗Benchmark →

How it works

  1. you speak
    48 kHz audio

  2. Whisper
    speech to text

  3. LLM
    streams tokens

  4. Kokoro
    speaks back

01 / Overview

Voice pipeline built from three standalone WebSocket microservices (STT, LLM, TTS) that are meant to plug into a backend orchestration layer. Whisper-based STT with VAD handles transcription, PydanticAI drives LLM inference with tool calling (DuckDuckGo search) on vLLM, with Ollama kept as a legacy backend without tool calling, and TTS runs through Kokoro (CPU/ONNX) or Chatterbox (GPU, multilingual). The frontend's WebSocket protocol streams partial and final transcripts, assistant tokens and TTS audio chunks, handles TTS interruption for barge-in, and tracks 11 timestamps that feed 9 derived latency metrics. The Next.js 16 frontend captures microphone audio through AudioWorklet processors running off the main thread, batches 48 kHz PCM into ~42 ms chunks, plays back TTS through a second worklet, and renders the full metrics dashboard with color-coded latency thresholds. The LLM and STT services ship Docker Compose files for GPU, CPU and Apple Silicon; the TTS service ships one CUDA image that runs Kokoro on CPU or Chatterbox on GPU.

02 / Key features

  • –WebSocket streaming for STT→LLM→TTS with barge-in (TTS interruption) and mid-stream generation cancel
  • –Kokoro (CPU/ONNX) and Chatterbox (GPU, multilingual) TTS engines, plus Whisper STT with VAD
  • –PydanticAI-driven LLM with DuckDuckGo tool calling on vLLM, with Ollama as a legacy backend
  • –AudioWorklet-based audio I/O — PCM capture at 48 kHz batched into ~42 ms chunks, TTS playback through a separate worklet, all off the main thread
  • –Nine latency metrics (STT FTL/FL, LLM TTFT/TTSR/TRT, TTS TAL/TST, E2E Total/User) with color-coded thresholds per metric
  • –Standalone microservices: LLM and STT with Docker Compose files for GPU, CPU and Apple Silicon, TTS as one CUDA image
  • –Three-column dashboard (conversations, chat, metrics) with collapsible side panels, live connection state, and recording/speaking indicators

03 / Challenges

  • –Keeping audio capture and playback off the main thread while synchronizing with React state — AudioWorklet processors run in a separate context with no direct DOM access
  • –Tracking latency across three independent services: 11 timestamps per utterance, each recorded at a different hop, then stitched into 9 meaningful metrics
  • –Handling barge-in — when the user talks over the reply, the frontend has to drop the TTS audio already queued in the playback worklet at once
  • –Supporting GPU, CPU, and Apple Silicon from the same codebase without a separate fork per platform

04 / Solution

Async WebSocket handlers carry STT/LLM/TTS streams with structured payloads, and the STT service uses VAD to detect end of speech. PydanticAI wraps the LLM layer with typed tool calling and conversation history trimming. The frontend uses two AudioWorklet processors — one for PCM capture with 2048-sample batching and an 8-byte header (timestamp + TTS-playing flag), another for buffered TTS playback — keeping audio processing off the main thread entirely. The LLM and STT services pick the platform through separate Docker Compose files (GPU, CPU, Apple Silicon) and environment config, and the TTS service picks its engine and device through environment variables.

05 / Outcome

Voice pipeline that runs locally as standalone microservices, with a vLLM backend (Ollama as legacy) and agentic tool calling via PydanticAI. The dashboard grades each metric against latency thresholds, for example end-to-end under 1 s is excellent and under 2 s acceptable. The frontend streams audio through AudioWorklet processors and renders a live metrics dashboard with per-metric color thresholds, so you can actually see where latency is going per hop.

06 / Services

  • STT Service ↗

    Whisper-based speech-to-text with VAD and word-level timestamps, exposed over WebSocket. Also runs in audio-file and live-microphone modes besides the WebSocket server.

    Faster-whisper · webrtcvad · FastAPI · WebSockets · Docker

  • LLM Service ↗

    vLLM (OpenAI-compatible) WebSocket LLM with PydanticAI agent layer, DuckDuckGo tool calling, conversation history trimming, and mid-stream request cancellation. Ollama remains as a legacy backend without tool calling.

    vLLM · PydanticAI · Ollama · FastAPI · WebSockets · Docker

  • TTS Service ↗

    Text-to-speech with Kokoro (CPU/ONNX) and Chatterbox (GPU, multilingual) backends selected by an environment variable, returning a synthesized WAV file per WebSocket request (Kokoro can also return MP3 and sends progress updates). The Kokoro layer builds on the open-source kokoro-tts project, and Chatterbox is Resemble AI's model.

    Kokoro · Chatterbox · PyTorch · Flask · WebSockets · Docker

  • Frontend ↗

    Next.js 16 voice-first dashboard with AudioWorklet-based PCM capture and TTS playback, three-column layout, nine latency metrics with color-coded thresholds, and auto-reconnecting WebSocket client.

    Next.js 16 · React 19 · Tailwind v4 · AudioWorklet API · Radix UI

Berkay Orhan© 2026

WorkResearchExperienceCVBack to top ↑