A simple voice assistant powered by ElevenLabs Conversational AI. It listens via your microphone, transcribes speech, and responds with synthesized voice.
flowchart LR
U[You 🎤] -->|speak| MIC[Microphone]
MIC --> E[ElevenLabs Conversational AI]
E -->|STT| T[Transcript 📝]
E -->|LLM| R[Response 💬]
E -->|TTS| S[Audio 🔊]
S --> SPK[Speakers]
-
Create an environment file locally (do not commit secrets):
- Copy
.env.exampletotest.env - Fill in values for
AGENT_IDandAPI_KEY
- Copy
-
Install dependencies:
pip install -r requirements.txtAlternatively (quick install, not pinned):
pip install "elevenlabs[pyaudio]" python-dotenvNote: Voice input/output relies on PortAudio.
- Linux:
sudo apt install portaudio19-dev- macOS:
brew install portaudio- (Windows) If PyAudio install fails, try:
pip install pipwin
pipwin install pyaudiopython -u voice_assistant.pySay “stop”, “exit”, “quit”, “bye”, “goodbye”, or “end session” to end the conversation.
Non-secret text is hardcoded in voice_assistant.py:
user_name: default is "Robil"prompt: default is "You are a helpful assistant."first_message: default greeting usinguser_name
You can change these lines directly if you want different behavior. Secrets (AGENT_ID, API_KEY) stay in test.env.
- Do not commit
test.envor any.envfiles. They are excluded by.gitignore. - Logs like
conversation_log.txtare ignored. - If a key is accidentally committed, rotate it in the ElevenLabs dashboard immediately.
- Create an agent in the ElevenLabs dashboard (Agents → New agent).
- In the agent editor:
- Set your System prompt and First message as desired.
- Open Security and enable Overrides for at least: First message and System prompt (so runtime overrides from the app are allowed).
- Click Publish to apply changes.
- Create an API key (Settings → API Keys) with permissions including ElevenLabs Agents Write (required for Conversational AI). Grant Text to Speech / Speech to Text access if you use audio.
- Copy the Agent ID into
AGENT_IDand the API key intoAPI_KEYin your localtest.env. - Ensure your account plan includes access to Conversational AI features.
This project was inspired by the Codédex tutorial “Create a Voice Virtual Assistant with ElevenLabs” by Alexandre Sajus:
I implemented my own version and added small improvements (logging, safer repo setup, and voice-session exit keywords).
This project is licensed under the MIT License. See LICENSE for details.