How fikrikarim/parlor works
Purpose and Entry Points
Parlor is a local-first, real-time multimodal voice assistant: browser microphone/camera input is processed by a Python server and returned as streamed transcripts and synthesized speech. The executable entry point is the parlor package/server, with the browser UI served by FastAPI.
• src/parlor/server.py
• src/parlor/web/index.html
• src/parlor/web/static/app.js
Connection and Session Orchestration
server.py owns the FastAPI application, HTTP UI serving, WebSocket endpoint, and per-connection conversation state. Each WebSocket session receives PCM audio and JPEG camera frames, manages interruption/barge-in, tracks conversation history and elapsed time, and emits transcript, UI-state, timer, and audio events.
• src/parlor/server.py
• src/parlor/modes.py
• src/parlor/pipeline.py
Browser Media Boundary
The browser captures microphone and camera data, uses client-side Silero VAD to detect speech/silence, sends media over WebSocket, and plays incremental TTS audio. It also renders transcript, timer, and mode state. VAD is deliberately client-side; semantic end-of-turn determination is server-side.
• src/parlor/web/static/app.js
• src/parlor/web/index.html
• src/parlor/web/static/style.css
Turn Detection and Multimodal Inference
Audio turns pass through smart-turn-v3 to distinguish completed utterances from mid-thought pauses. The local Gemma model, hosted through llama-server, consumes audio, current camera context, history, session timing, and mode instructions. Input can be prefetched into llama.cpp’s prompt cache while the user is speaking to reduce response latency.
• src/parlor/turn_detector.py
• src/parlor/llama.py
• src/parlor/server.py
Streaming Response Pipeline
The response pipeline commits and publishes recognized user transcript content, streams model output, segments it into speakable sentences, and feeds sentences to TTS as generation continues. Barge-in cancels active model/TTS work rather than waiting for a full response.
• src/parlor/pipeline.py
• src/parlor/llama.py
• src/parlor/tts.py
Actions, Modes, and Server-Owned Timers
Control is separated from spoken generation. A second grammar-constrained JSON inference pass decides actions such as timer creation/cancellation, translation/listen mode changes, and research delegation; its markup never reaches TTS. modes.py changes turn behavior: conversation replies, consecutive translation, or silent transcription. Timers are maintained by the server so they can fire independently of a subsequent user turn.
• src/parlor/actions.py
• src/parlor/modes.py
• src/parlor/server.py
Optional Background Research
Research actions are delegated asynchronously while local conversation remains responsive. The reasoner calls a configurable OpenAI-compatible endpoint—defaulting to OpenRouter—and later injects/speaks its result. Without REASONER_API_KEY, this branch is disabled and operation remains on-device.
• src/parlor/reasoner.py
• src/parlor/actions.py
• .env.example
Runtime and Model Infrastructure
Python 3.12+ runs FastAPI and the orchestration stack. llama.cpp is an external local inference runtime for quantized Gemma 4 plus multimodal projector; models download on demand. Kokoro TTS uses MLX on Apple Silicon and ONNX on Linux/GPU-capable environments. smart-turn-v3 is a local turn-classification dependency.
• pyproject.toml
• src/parlor/llama.py
• src/parlor/tts.py
Main entry points: server.py FastAPI + WebSocket · pipeline.py Streaming response pipeline · actions.py Action planner · app.js Media client
Components 15
Browser client
- Web UI · Renders transcript, timer, and mode state.
src/parlor/web/index.html - Media client · Captures mic/camera and plays streamed speech.
src/parlor/web/static/app.js - Client-side VAD · Detects local speech and silence.
src/parlor/web/static/app.js
Python session server
- FastAPI + WebSocket · Serves the UI and owns per-connection state.
src/parlor/server.py - Conversation session · Tracks history, camera context, elapsed time, and interruption.
src/parlor/server.py - Server timers · Fires independently of later user turns.
src/parlor/server.py - Interaction modes · Conversation, translation, and silent transcription behavior.
src/parlor/modes.py - Action planner · Separates control markup from spoken output.
src/parlor/actions.py
Local AI pipeline
- Semantic turn detector · Distinguishes completed turns from mid-thought pauses.
src/parlor/turn_detector.py - Streaming response pipeline · Publishes transcripts, segments output, and cancels on barge-in.
src/parlor/pipeline.py - Llama inference adapter · Prefetches prompt context and streams local multimodal generation.
src/parlor/llama.py - llama-server + Gemma · Hosts quantized Gemma 4 with the multimodal projector.
src/parlor/llama.py - Streaming TTS · Uses MLX or ONNX according to platform.
src/parlor/tts.py
Optional research
Disabled without a reasoner API key.
- Research reasoner · Delegates background research without blocking conversation.
src/parlor/reasoner.py - Compatible reasoning endpoint · Defaults to OpenRouter when configured.
.env.example
Connections 22
- Web UI → Media client: hosts controls
- Media client → Client-side VAD: audio frames
- Media client → FastAPI + WebSocket: WebSocket PCM, JPEG, events
- Client-side VAD → FastAPI + WebSocket: speech/silence signals
- FastAPI + WebSocket → Conversation session: creates and updates
- FastAPI + WebSocket → Semantic turn detector: audio turns
- Semantic turn detector → Streaming response pipeline: completed utterance
- Conversation session → Streaming response pipeline: history, vision, timing
- Interaction modes → Streaming response pipeline: response policy
- Streaming response pipeline → Llama inference adapter: stream generation
- Llama inference adapter → llama-server + Gemma: prompt cache and inference
- Streaming response pipeline → Action planner: control decision
- Action planner → Interaction modes: mode changes
- Action planner → Server timers: create or cancel
- Action planner → Research reasoner: research delegation
- Research reasoner → Compatible reasoning endpoint: configured request
- Research reasoner → Streaming response pipeline: later result
- Streaming response pipeline → Streaming TTS: speakable sentences
- Streaming TTS → FastAPI + WebSocket: incremental audio
- FastAPI + WebSocket → Media client: transcript, state, timer, audio
- FastAPI + WebSocket → Streaming response pipeline: barge-in cancellation
- Server timers → FastAPI + WebSocket: timer events