VoiceMem: memory system for real-time voice agents
VoiceMem is a memory system built for real-time voice agents.
Verified
Core facts
Read by a script from the official API, not rewritten by a model.
- Repository
- https://github.com/xzf-thu/VoiceMem
- License
- Apache-2.0
- Languages
- Python
- Maintainer
- xzf-thu
- Verified
What it is
VoiceMem is a memory system built for real-time voice agents. Instead of storing every type of memory in a single retrieval database, VoiceMem separates memory into two complementary parts. Left Brain organizes factual memory using schemas and entities. Right Brain manages personality, emotion, and relationships using independent and cross-entity memory nodes.
Main features
The entire pipeline is streaming.
While the user is still speaking, VoiceMem continuously segments audio, transcribes speech, extracts useful memories, and writes structured information into the memory graph.
At query time, VoiceMem routes first, ranks second, and injects only the Top-K memories into the model context.
VoiceMem remembers speech, speakers, sound events, multi-speaker conversations, and music from real-world audio.
The project reports that VoiceMem reaches 91.2% on LoCoMo, compared with 61.68% for Mem0, using only Top-5 memories.
The project reports that VoiceMem responds in 134 ms, compared with 1,440 ms for Mem0, with streaming retrieval inside the voice turn.
Getting started
The installation prerequisite for VoiceMem is Python 3.10 or later.
Think of VoiceMem's streaming interface as a VAD interface that continuously processes audio.
The demo lives in the repo and the pip package ships the library only, so the repo must be cloned and entered at its root.
Barge-in in the demo uses two stages during playback.
In barge-in handling, VAD first pauses playback while preserving the audio queue.
Both reply modes of the demo share a PCM-sample media timeline.
git clone https://github.com/xzf-thu/VoiceMem.git
cd VoiceMem
# Install the memory system (bundles ASR / speaker ID / scene / emotion / local embedding)
pip install voicemem
# Optional: run our fine-tuned Qwen reply model
pip install "voicemem[slm]"pip install -U huggingface_hub
hf download zhifeixie/VoiceMem_Default_Models_Env --local-dir ./modelsfrom voicemem import VoiceMem
vm = VoiceMem(
mode="normal",
openai_key="api_xxx",
top_k=5,
)
# Local models load lazily -- warm them up so the first call doesn't pay for it.
vm.warmup()
# Store an audio file.
# VoiceMem internally runs ASR / speaker ID / scene / emotion / embedding extraction.
print("ingest start")
vm.ingest(audio="assets/input.wav") # I am vegetarian and allergic to nuts.
print("ingest done")
# Writing is slow because it extracts facts, tags them and builds the graph.
# Reading is a pure vector lookup -- independent of write cost.
print("search start")
result = vm.search("What are my dietary restrictions?")
print("search done")
print(result.result_leftbrain, result.result_rightbrain)
# Store Left Brain factual text directly (no emotional information).
vm = VoiceMem(
mode="leftbrain_only",
openai_key="api_xxx",
top_k=5,
)
vm.ingest("I am vegetarian and allergic to nuts.")
result = vm.search("What are my dietary restrictions?")import asyncio
import os
from pprint import pprint
import numpy as np
import soundfile as sf
from voicemem import VoiceMem
# Reuses the vm above; building one here so the block runs standalone
vm = VoiceMem(mode="normal", openai_key=os.environ["OPENAI_API_KEY"], top_k=5)
# Local models load lazily -- warm them up so the first audio chunk doesn't wait
vm.warmup()
# Store one fact first, so the question below has something to find
vm.ingest("I am vegetarian and allergic to nuts.")
SPEC_MIN_CHARS = 6
searching = False
def on_partial(text):
"""Partial transcripts as they arrive. Long enough = the search already started."""
global searching
print(f"\r[partial] {text}", end="", flush=True)
if not searching and len(text) >= SPEC_MIN_CHARS:
searching = True
print("\n[search start] speaker isn't done yet, retrieval already running", flush=True)
async def main():
# This audio is a question: "What are my dietary restrictions?"
audio, sr = sf.read("assets/question.wav", dtype="float32")
pcm = (np.clip(audio, -1, 1) * 32767).astype(np.int16)
stream = vm.stream(src_rate=sr, vad_threshold=0.5, on_partial=on_partial)
step = int(sr * .032)
for i in range(0, len(pcm), step):
st = await stream.feed(pcm[i:i + step].tobytes())
if st.state != "turn_over":
continue
# VAD confirmed end of turn. Memory was fetched while the user spoke -- just read it
print("[search end]")
print("transcript ", st.transcript)
print("left brain ", st.result_leftbrain)
print("right brain ", st.result_rightbrain)
pprint({k: getattr(st, k) for k in
["speaker_id", "speaker_voiceprint", "emotion",
"entity", "schema", "text_embedding"]})
# Every turn runs the ingest decision
print("[ingest] LLM deciding whether this is worth storing...", flush=True)
res = vm.ingest(st.transcript)
print(f"[ingest] extracted {res['facts_count']} facts -> {res['memory_ids']}")
asyncio.run(main())python web/run.pyhttp://localhost:8787Who it is for
VoiceMem can be integrated with your own voice model to build a real-time voice agent with long-term memory. The project built ChatMem-400K through a three-stage OPD training pipeline. After human editing, the same pipeline produces ChatMem-Bench, which evaluates whether a voice model can build a long-term understanding of the user over time.
The open-source VoiceMem model family includes Qwen2.5-Omni, Qwen3-Omni, and Step-Audio2-Mini. These models can receive and understand memory information provided by VoiceMem during conversations. VoiceMem provides the complete finetuning pipeline for training your own VoiceMem Model Family adapter.
The default finetuning training configuration matches the one used for the released checkpoint-3318. The evaluation pipeline is fully open source and reproducible. A benchmark can be started with a single command.
Before running a full evaluation, the inspect option can be added to check how the dataset is parsed. The inspect mode does not call the model and does not incur API costs. During evaluation, the answering model receives only the retrieved memories, not the original conversation history.
Adding a benchmark only requires one file and two functions. The project reports that VoiceMem uses only 430 memory tokens, compared with 6,956 for Mem0 and 1,899 for EverMemOS. The project states that each query uses about 300 tokens.
VoiceMem is open source under the Apache License 2.0. VoiceMem also uses OpenAI APIs for Chat, TTS, and Realtime functionality.
Sources
This page is written from the official sources below. Open them to check the original text.
- GitHub READMEhttps://github.com/xzf-thu/VoiceMemFetched
Verified ·
This page is written by AI from the official sources above and checked automatically. This site has not tested it. Found a mistake? Tell us.