Talk to your AI agent like a phone call.
Mic → Whisper → OpenClaw → TTS → Speaker
A continuous voice conversation loop that captures your speech, transcribes it locally with Whisper, sends it to any OpenClaw gateway (any model), and speaks the response back to you.
- Listen — Records from your mic, detects speech, stops on silence
- Transcribe — Local Whisper model converts speech to text
- Think — Sends text to your OpenClaw agent via
openclaw agentCLI - Speak — Converts the reply to audio via ElevenLabs, OpenAI TTS, Edge TTS, or macOS
say(unless the agent already generated audio itself via attstool, in which case that's played directly) - Repeat
Works with any OpenClaw gateway and any model configured on that gateway (Claude, GPT, Gemini, local models, etc.).
- Python 3.9+
- OpenClaw CLI installed and configured
- ffmpeg and portaudio
brew install ffmpeg portaudiosudo apt install ffmpeg portaudio19-devgit clone https://github.com/jdawe/openclaw-voice-loop.git
cd openclaw-voice-loop
pip install -r requirements.txt# Basic — uses Edge TTS if installed, else macOS `say`
python voice_loop.py
# With ElevenLabs TTS (highest quality)
export ELEVENLABS_API_KEY=your_key_here
python voice_loop.py
# With OpenAI TTS
export OPENAI_API_KEY=your_key_here
export OPENAI_VOICE=nova # optional, default: alloy
python voice_loop.py
# With a remote OpenClaw gateway
export OPENCLAW_GATEWAY_URL=wss://your-gateway.example.com
export OPENCLAW_GATEWAY_TOKEN=your_token
python voice_loop.pyAll configuration is via environment variables:
TTS priority: ElevenLabs → OpenAI → Edge TTS → macOS say (first available option wins;
each tier falls through to the next on failure).
| Variable | Default | Description |
|---|---|---|
ELEVENLABS_API_KEY |
(none) | ElevenLabs API key (highest TTS priority). Falls back to ~/.config/elevenlabs/config.json ({"api_key": "..."}) if unset |
ELEVENLABS_VOICE_ID |
21m00Tcm4TlvDq8ikWAM |
ElevenLabs voice ID (default: Rachel) |
ELEVENLABS_SPEED |
1.0 |
Playback speed multiplier |
OPENAI_API_KEY |
(none) | OpenAI API key (second TTS priority) |
OPENAI_VOICE |
alloy |
OpenAI TTS voice: alloy, echo, fable, onyx, nova, shimmer |
EDGE_TTS_VOICE |
en-US-AriaNeural |
Edge TTS voice, used if no API key is set and edge-tts is installed |
WHISPER_MODEL |
tiny |
Whisper model: tiny, base, small, medium, large |
OPENCLAW_GATEWAY_URL |
(none) | Remote gateway WebSocket URL |
OPENCLAW_GATEWAY_TOKEN |
(none) | Gateway auth token |
VOICE_SESSION_ID |
voice-loop |
OpenClaw session ID (maintains conversation context) |
VOICE_MODEL |
(gateway default) | Model override, e.g. anthropic/claude-sonnet-5. Voice conversations want low latency — the gateway's default model may be larger/slower than that calls for. Must be one of your gateway's configured primary/fallback models |
AGENT_TIMEOUT |
60 |
Seconds to wait for agent reply |
SAY_RATE |
350 |
macOS say words per minute |
MAX_TURNS |
50 |
Max conversation turns before auto-reset |
TTS_STRICT |
(off) | If set, a TTS provider failure raises an error instead of silently falling through to the next tier. Use this if hearing the wrong voice would be worse than hearing nothing |
TTS_PROVIDER |
(auto) | Pin the provider explicitly: elevenlabs, openai, edge, or macos. Skips auto-pick-by-key-presence — useful if a stale key shouldn't silently decide the voice |
- First run downloads the Whisper model (~75MB for
tiny). Subsequent runs are instant. - Use
tinyorbaseWhisper models for fastest transcription.smallis a good accuracy/speed tradeoff. - The loop auto-calibrates your mic on startup — stay quiet for 1 second.
- Whisper hallucination filtering is built in (ignores phantom "thank you" / "bye" transcriptions).
- Sessions persist across turns, so the agent remembers context within a conversation.
MIT