# Repository Briefing: xzf-thu/VoiceMem
> Source: https://repoforai.com/repo/xzf-thu/VoiceMem (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/xzf-thu/VoiceMem
- **Category**: RAG, Data & Memory (知识库 / 爬虫 / 记忆层)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: B+ (75/100 · Maintenance 20/35 · Adoption 18/25 · Releases 17/20 · License 20/20)
- **Latest Release**: v0.0.2 (2026-09-01) — https://github.com/xzf-thu/VoiceMem/releases
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: Local AI, API
- **Momentum**: 2,907 ★ total (+1 24h / +3 7d) · 268 forks
- **Topics**: `ai`, `ai-agents`, `ai-tools`, `application`, `audio-streaming`, `genai`, `llm`, `long-term-memory`, `memory`, `memory-management`, `python`, `voice-agent`
- **When to Use**: Best for: Real-time voice assistants that need persistent facts and personal context, want recall to begin during speech, and can validate their own model backends and audio latency. Skip if: You only need a general-purpose vector store or finalized-text retrieval, or you require a turnkey, fully offline, multi-tenant service with established production guarantees.

## Overview
```text
### Architecture & Core Mechanics
VoiceMem is a Python memory layer for voice agents, not a general-purpose vector database. Its “left brain” organizes factual memory by schema and entity; its “right brain” models emotion, personality, and relationships with standalone and cross-entity nodes. Retrieval routes a query before ranking candidates, then supplies only the Top-K memories to the reply model. Writes do more work: extract facts, label them, and update the memory graph.

The base package bundles VAD, ASR, speaker identification, scene and emotion models, and local embeddings. Partial transcripts can trigger speculative retrieval while the user is still speaking. The streaming example feeds PCM chunks asynchronously and reads results when VAD closes the turn; it then calls text ingestion explicitly, so finishing a stream turn is not itself a persistence guarantee. A `reply` callback keeps the response model separate from memory retrieval.

### Key Capabilities & Differentiators
The API supports direct text and audio-file ingestion as well as streaming PCM. `leftbrain_only` is available for fact-only workloads. Streaming results can include speaker ID and voiceprint, emotion, schema, entity, and text embedding alongside the transcript and recalled memories. Memory-aware model families include Qwen2.5-Omni, Qwen3-Omni, and Step-Audio2-Mini; `finetune/train.py` provides an adapter training path rather than making those models a runtime requirement for every integration.

Published figures include 91.2% on LoCoMo at Top-5, 69.44% on PersonaMem, 134 ms response time, and 430 memory-context tokens. A separate LoCoMo CLI example reports 139/152 (91.4%), 12 ms median retrieval latency, and 298 median retrieved tokens. These are distinct measurements: retrieval latency is not end-to-end time to audible reply. The evaluation runner withholds raw dialogue history from the answering model, so answers depend on what retrieval actually supplies.

### Trade-offs & Limitations
Compared with using Mem0 or EverMemOS strictly as text-memory baselines, VoiceMem's distinguishing design is its audio perception layer and ability to start recall before turn completion. The published comparison is useful for choosing what to test, not for predicting production latency or cost. Top-K limits the prompt footprint but can omit context for multi-hop or temporal questions. Preserving dated facts is preferable to overwriting them when users' circumstances change, but the reply model still has to interpret which fact is current.

Prefetch moves retrieval off part of the post-turn critical path; it does not remove final ASR processing, generation, or TTS. Measure latency to the first audible reply, write-to-recall lag, and recall quality when partial transcripts change. Voiceprints and inferred emotional attributes also raise the cost of operating this layer: set consent, access, retention, and deletion rules. Treat the demo's session and memory-space separation as behavior to verify, not as proof of production tenant isolation.

### Hardware & Deployment Guide
Use Python 3.10+ and install with `pip install voicemem`. Download `zhifeixie/VoiceMem_Default_Models_Env` into `./models` with `hf download`, then call `vm.warmup()` so lazy initialization does not land on the first audio chunk. The optional `voicemem[slm]` extra is shown for the fine-tuned Qwen reply path. Local retrieval does not establish a fully offline pipeline: the normal ingestion and streaming examples configure an OpenAI key. Verify extraction and reply backends separately before deploying without network access.

For the browser demo, clone the repository and run `python web/run.py`; it listens at `localhost:8787`. Terminal logs are written to disk by default; use `--no-file-log` to disable that file output. The v0.0.2 release fixes event-date propagation, removes the unused `response_experience` category, and makes TTS pluggable. The supplied `pyproject.toml` shows 0.2.3 while the GitHub release tag is v0.0.2, so pin and test the exact package or checkout you deploy.
```

## Key Capabilities
```text
- Memory structure: Schema- and entity-organized facts are separate from emotion, personality, and relationship nodes.
- Turn-level prefetch: Partial ASR text can trigger retrieval before VAD closes the turn; the streaming API exposes results at `turn_over`.
- Temporal recall: v0.0.2 carries event dates into retrieval and context, allowing older and newer facts to coexist.
- Replaceable generation and speech: `VoiceMem(reply=...)` accepts a custom generator, and the demo's TTS interface can return `TimedAudioChunk` for text alignment.
- Playback-aware session history: The WebSocket demo tracks rendered audio so an interruption does not record the unplayed reply as heard.
- Controlled memory evaluation: `evaluation/run.py` withholds raw dialogue history from the answer model; `--inspect` parses inputs without model calls.
```

## Quick Start / Clone
```bash
git clone https://github.com/xzf-thu/VoiceMem.git
cd VoiceMem

# 安装记忆系统（含 ASR / 声纹 / 场景 / 情绪 / 本地 embedding 全套内置组件）
pip install voicemem

# 可选：用我们微调的 Qwen 回复模型
pip install "voicemem[slm]"
```
