A simple CLI-based LiveKit voice agent using Deepgram for STT/TTS and OpenAI for the LLM.
- 🎤 Voice Input via CLI: Speak naturally using
voice_agent.py console - 🔊 Voice Output: Get responses with speech
- 💬 Conversational: Natural language interaction
- ⚙️ STT/TTS with Deepgram: Using Flux for STT and Aura-2 for TTS
- 🤖 LLM with OpenAI: GPT models for understanding
- 🔧 LiveKit Agent: Traditional LiveKit agent architecture
- Python 3.9 or higher
- UV package manager (or pip)
- API keys for:
-
Install dependencies:
uv sync # OR pip install -r requirements.txt -
Set up environment variables:
cp env.template .env
Edit
.envand add your API keys:DEEPGRAM_API_KEY=your_deepgram_api_key_here OPENAI_API_KEY=your_openai_api_key_here LIVEKIT_URL=wss://your-livekit-server.com LIVEKIT_API_KEY=your_livekit_api_key_here LIVEKIT_API_SECRET=your_livekit_api_secret_here
# Start in dev mode (watches for changes)
uv run python voice_agent.py dev
# Or without dev mode
uv run python voice_agent.pyIn another terminal:
# Connect using built-in console command
uv run python voice_agent.py consoleThis will:
- Connect to the LiveKit room
- Enable your microphone
- Start listening for your voice
- Display transcripts in the terminal
- Play agent responses through your speakers
The agent configuration is in voice_agent.py. You can modify:
- STT Model: Deepgram model (default:
flux-general-en) - TTS Model: Deepgram model (default:
aura-2-andromeda-en) - LLM Model: OpenAI model (default:
gpt-4o) - Temperature: LLM randomness (default:
0.7) - Max Tokens: Response length (default:
1000) - Key Terms: STT recognition terms
Example:
self.config = {
'stt_model': 'flux-general-en',
'stt_keyterms': ['flight', 'departure', 'arrival', 'airline', 'booking', 'travel', 'trip'],
'stt_eager_eot_threshold': 0.4,
'tts_model': 'aura-2-andromeda-en',
'llm_model': 'gpt-4o',
'llm_temperature': 0.7,
'llm_max_tokens': 1000
}.
├── voice_agent.py # Main voice agent implementation
├── main.py # Entry point
├── requirements.txt # Python dependencies
├── pyproject.toml # UV configuration
├── env.template # Environment variables template
├── generate_token.py # Utility for generating LiveKit tokens
└── README.md # This file
- Go to Deepgram Console
- Sign up or log in
- Create a new project
- Copy your API key
- Go to OpenAI Platform
- Sign up or log in
- Navigate to API Keys
- Create a new secret key
- Go to LiveKit Cloud
- Create a new project
- Copy the WebSocket URL, API Key, and API Secret
- Check your
.envfile has all required keys - Verify API keys are correct
- Verify LIVEKIT_URL, API_KEY, and API_SECRET are correct
- Check network connectivity
- Grant microphone permissions
- Ensure microphone is not used by another app
- Try restarting the console command
MIT