Credentials. The example needs an OPENAI_API_KEY, which should be kept in an environment variable and not committed to code.
Who it is forA developer building a real-time voice agent who wants it to remember a user's preferences and past conversations.
The problemA voice model forgets everything between sessions, so users repeat themselves and the agent cannot adapt to who they are.
The outcomeYour reply model gets a short set of retrieved memories as context before it answers, and only the reply function changes.
What you need first
- Python 3.10 or newer
- An OpenAI API key, used for fact extraction when memories are written
- Git and access to GitHub and Hugging Face to clone the repo and download the default models
- Audio input (a WAV file or a microphone) if you want to ingest speech
Steps
- Clone the repo with
git clone https://github.com/xzf-thu/VoiceMem.gitand enter the folder withcd VoiceMem. - Install the memory system with
pip install voicemem. - Download the default local models with
pip install -U huggingface_huband thenhf download zhifeixie/VoiceMem_Default_Models_Env --local-dir ./models. - Set your key with
export OPENAI_API_KEY=sk-.... - Run the sample agent with
python examples/03_simple_agent_with_voicemem_memory.py, then replace the generation step with your own model in a function that takes text and memory_context.
Prompt for your agent
Using the VoiceMem repo at <repo path>, wire my model <model name> into a reply function with signature my_reply(text, memory_context) and pass it to VoiceMem(reply=my_reply). Confirm the sample script runs and that memory_context is non-empty after I state a fact such as a food allergy.
Caveat. Memory writes call the OpenAI API for fact extraction, while memory retrieval runs locally according to the README.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for xzf-thu/VoiceMem and "Give a custom voice agent long-term memory"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer