A local, low-latency voice assistant built on Liquid LFM3-Audio 2B and llama-server.
VoxLoop turns a microphone into a real conversation loop: incremental speech capture, voice activity detection, a replaceable turn-taking engine, streamed text and audio from the model, and interruption handling that stops the answer when you start talking.
No cloud APIs. No OpenAI SDK. One local model, one WebSocket, and a Python agent.
- Local and private. Audio never leaves the machine.
- Incremental input. Listening audio is appended to the live model session as it arrives, so end of speech to first token is roughly constant regardless of clip length.
- Explicit turn taking. A decision engine emits
LISTEN,SPEAK,CONTINUE, orYIELD, separate from audio capture and inference. - Barge-in. Sustained user speech cancels the response, retains the interrupting audio, and replays it as the next turn.
- Replaceable policy. Swap the rule-based policy for a custom one without touching audio or inference code.
- Measured, not guessed. Every phase in
spec/includes reproducible probes, numbers, and known limits.
microphone / WAV
|
v
capture (100 ms chunks)
|
v
WebRTC VAD ---> TurnController ---> DecisionPolicy ---> DecisionValidator
| |
| v
| SPEAK / YIELD
v |
IncrementalTracker v
| RealtimeSession
v |
/v1/realtime (WebSocket) <--------------------+
|
+--> text deltas --> console
|
+--> audio deltas --> PCMPlayer --> speakers
The model is half-duplex: it cannot hear new audio while it generates. VoxLoop keeps capture and the decision engine alive during generation and playback, then implements full-duplex behavior as interrupt, cancel, retain, replay.
| Phase | What it established | Report |
|---|---|---|
| 1 | Realtime protocol, incremental prefill, cancellation semantics, VRAM footprint | spec/phase1-report.md |
| 2 | Working local voice agent: mic, VAD, end of turn, streamed speech | spec/phase2-report.md |
| 3 | Incremental audio streaming and context accounting | spec/phase3-report.md |
| 4 | Independent decision engine and validation layer | spec/phase4-report.md |
| 5 | Full-duplex interruption, audio retention, echo guard, shadow mode | spec/phase5-report.md |
Acoustic echo cancellation is not part of this snapshot. A model-level echo guard suppresses self-triggered interruptions, but it is a heuristic, not AEC. Headphones are the reliable option for hands-free barge-in.
- Windows 10 or 11 (the launch scripts and device notes target Windows)
- Python 3.10 or newer
- A
llama-serverbuild with multimodal audio support - LFM3-Audio 2B in GGUF format plus its audio projector
- A microphone and speakers or headphones
Tested on an RTX 5050 Laptop with 8 GB VRAM using the Q8_0 model. Q4_K_M also fits and uses roughly 1 GiB less VRAM.
| Piece | Example file | Size |
|---|---|---|
| Language model, Q8_0 | LFM3-Audio-2B-Q8_0.gguf |
1.8 GB |
| Audio projector, Q8_0 | mmproj-LFM3-Audio-2B-Q8_0.gguf |
304 MB |
| Language model, Q4_K_M | LFM3-Audio-2B-Q4_K_M.gguf |
1.1 GB |
| Audio projector, Q4_K_M | mmproj-LFM3-Audio-2B-Q4_K_M.gguf |
172 MB |
git clone https://github.com/baka-onii/VoxLoop.git
cd VoxLoop
python -m venv .venv
.venv\Scripts\activate
python -m pip install -r requirements.txtPoint the launcher at your model files. The scripts read these environment variables:
$env:MODEL = "C:\models\LFM3-Audio-2B-Q8_0.gguf"
$env:MMPROJ = "C:\models\mmproj-LFM3-Audio-2B-Q8_0.gguf"
.\start-server.batIf llama-server.exe is not in E:\llama.cpp, set LLAMA_DIR first:
$env:LLAMA_DIR = "C:\llama.cpp"MEDIA_PATH defaults to the repository root and controls which local files may be
referenced with file://.
The server listens on http://127.0.0.1:9931 with all layers on the GPU, 8192 context,
four slots, and the alias lfm3-audio. Extra arguments are forwarded:
.\start-server.bat --port 8080
.\start-server-q4.batCheck it before starting the agent:
curl.exe http://127.0.0.1:9931/health
# {"status":"ok"}Then run the agent:
python -m src.mainSpeak. VoxLoop detects the end of your turn, streams the answer, and plays it as it
arrives. Press Ctrl+C to stop.
python -m src.main # microphone and speakers
python -m src.main --list-devices # list input/output indexes
python -m src.main --input-device 2 # pick a specific microphone
python -m src.main --wav example.wav --once # replay one clip
python -m src.main --wav example.wav --once --no-playback --save-response out.wav
python -m src.main --wav example.wav --loop-wav --duration 20
python -m src.main --no-barge-in # shadow decisions, never cancelUseful controls:
| Flag | Purpose |
|---|---|
--append-mode continuous |
Stream every listening chunk into the session (default) |
--append-mode utterance |
Only stream from pre-roll to commit |
--idle-silence-cap-ms N |
Stop appending idle silence after N ms (0 = never) |
--prefill-settle-ms N |
Wait between commit and response.create for burst input |
--max-turns N |
Exit after N responses |
--duration N |
Exit after N seconds |
--input-gain-db N |
Digital boost for quiet array microphones |
--input-channel auto |
Pick the loudest channel of an array microphone |
The default input device on some machines is a virtual or muted microphone. Use
--list-devices and select a real input explicitly.
- Capture produces 100 ms PCM chunks at 16 kHz.
- WebRTC VAD labels speech inside each chunk.
TurnControlleropens an utterance after 240 ms of recent speech and ignores isolated clicks.- While listening, chunks are appended to
/v1/realtimeincontinuousmode. The server encodes them into context as they arrive, without generating. - After 700 ms of trailing silence, the policy emits
SPEAK. - The agent sends
input_audio_buffer.commit, thenresponse.create. - Text and audio deltas stream back. Audio is queued to PortAudio immediately.
- If you speak for 400 ms while the agent is active, the policy emits
YIELD. YIELDflushes playback, cancels generation, retains audio from 400 ms before onset, sends an interruption notice, and replays the retained audio as the next turn.
Important model behavior:
- Keep the system prompt short. A verbose prompt makes the model transcribe the user instead of answering.
- Request
output_modalities: [text, audio]. Audio-only output is shorter and less accurate on the tested build. - The server has no VAD. End-of-turn detection is entirely client side.
RTX 5050 Laptop, 8 GB VRAM, Q8_0, all layers on GPU:
| Task | Result | Notes |
|---|---|---|
| TTS, 4.16 s of speech | 953 ms | About 4.4x realtime |
| Transcript, 2.67 s clip | 293 ms | Includes Python startup |
| Streaming ASR, 2.67 s clip | 1.19 s | Includes client resampling and chunking |
| Realtime answer, 23.76 s paced | 122 ms to first output | After the last chunk |
| Agent, 2.67 s clip | about 0.82 s from end of speech to audio | 710 ms silence plus 113 ms to first audio |
| Incremental prefill, 5/20/60 s | about 50 ms to first text | Independent of clip length |
| End of turn | 700 ms trailing silence | A 400 ms pause does not end the turn |
| Barge-in | 400 ms sustained speech | Live agent path yielded at 420 to 480 ms |
Detailed numbers, methods, and caveats live in the phase reports under spec/.
LFM3-Audio is a conversational audio model, not a pure ASR engine. The endpoint you choose decides whether it transcribes or answers.
python transcribe.py
python transcribe.py "D:\clips\take1.wav"Uses /v1/chat/completions with the system prompt
"Transcribe the audio verbatim. Include contractions exactly as spoken." and the audio
as the only user content. This is the most accurate one-shot transcription path.
Measured on TTS round trips (4 of 4 content-correct):
| Spoken | Transcript |
|---|---|
| What is the capital of France? | What is the capital of France? |
| The quick brown fox jumps over the lazy dog, and the weather is unusually warm today. | identical |
| I paid 42 dollars at the store on January 3rd, then drove home. | I paid forty two dollars at the store on January third, then drove home. |
| Could you send me the quarterly report by Friday, please? | identical |
Numbers are normalized to words. Everything else is word-perfect in these samples.
python realtime_transcribe.py
python realtime_transcribe.py audio.wav enUses /v1/realtime?intent=transcription and emits word-by-word deltas while audio is
fed in 100 ms chunks. It is less accurate on short clips, so prefer transcribe.py for
one-shot work.
python ask_audio.py
python ask_audio.py clip.wav "How many speakers are there?"This is the model doing what it was trained for: hearing audio and answering questions about it.
python phase1\minimal.py
python phase1\minimal.py "D:\clips\take1.wav"Connects to the conversation session, streams a clip, commits, and prints the spoken answer. No SDK required.
@'
import json, urllib.request
req = urllib.request.Request(
"http://127.0.0.1:9931/tts",
data=json.dumps({"input": "Hello from VoxLoop.", "voice": "female"}).encode(),
headers={"Content-Type": "application/json"})
open("out.wav", "wb").write(urllib.request.urlopen(req, timeout=300).read())
'@ | python -Voices are female and male. Output is 24 kHz mono WAV. A reference clip
(speaker_ref as multipart, or speaker_ref_b64) clones that voice and clearly
improves stability.
Edit config/config.yaml. The main sections:
| Section | Controls |
|---|---|
model |
Realtime URL, instructions, interruption notice, output modalities |
audio |
Input and output rate, chunk size, device, pre-roll, WAV behavior |
decision |
VAD aggressiveness, silence thresholds, barge-in, echo guard |
playback |
Streaming, block size, volume |
incremental |
Append mode, idle silence cap, context estimate parameters |
logging |
State log and metrics log paths |
State transitions are written to logs/states.jsonl. Timings and decisions are written
to logs/metrics.jsonl. Both are ignored by git.
config/config.yaml runtime configuration
src/main.py CLI entry point
src/config.py typed configuration
src/audio/ capture, playback, chunk buffer, echo guard, WAV helpers
src/decision/ VAD tracker, turn controller, policy, validator
src/conversation/ agent orchestration and state machine
src/inference/ WebSocket session and incremental tracker
src/monitoring/ JSONL metrics and state logs
phase1/ ... phase5/ phase probes, fixtures, and results
spec/ phase reports and design notes
tests/ unit and headless integration tests
python -m pytest -qThe suite covers the state machine, VAD, turn controller, decision policy and validator, incremental accounting, the agent flow with a fake session, and Phase 5 interruption paths. Most tests need no microphone and no server.
Probe scripts reproduce the measurements in the reports:
python phase1\probe.py session
python phase3\probe_incremental.py --quick
python phase4\probe_decision.py
python phase5\probe_full_duplex.py- Half-duplex model. Audio appended during generation waits in a queue. The client serializes turns and implements barge-in as cancel, then listen.
- No context rollback. A cancelled answer stays in server context. The interruption notice anchors the next answer on the new question.
- No conversation reset API. Restart the agent for a clean context.
cleardoes not reset the conversation. - Echo guard, not AEC. The guard compares playback and microphone envelopes and suppresses likely self-triggered interruptions. Loud double-talk is allowed through. Open speakers can still self-trigger, so headphones are recommended.
- Context growth. Audio occupies model positions continuously. The tracker warns at 75 percent of 8192 positions.
- Media path. Local audio referenced by
file://must live underllama-server's--media-path. Outside it, send base64 audio instead. - Experimental audio input.
llama-serverstill flags audio input as experimental.
A future phase will add acoustic processing ahead of the VAD: echo cancellation with a timestamped playback reference, noise suppression, a high-pass filter, optional AGC, and audio diagnostics. It is intentionally excluded from this snapshot.
Released under the MIT License.
- Liquid AI for LFM3-Audio 2B
- ggml-org / llama.cpp for
llama-server - WebRTC VAD for lightweight voice activity detection