fix(real-time-voicebot): use env vars for API keys
Hey! Noticed the real-time-voicebot project had hardcoded API keys in the code which isn't great for security or usability.
Made a few changes:
- Moved API keys to env vars using python-dotenv
- Added .env.example so poeple know what keys they need
- Updated the README with setup steps
Follows the same pattern as rag-voice-agent and other projects in the repo. Let me know if you want any changes!
Summary by CodeRabbit
-
New Features
- Environment-based API key configuration via .env for simpler, more secure setup.
-
Improvements
- Startup now validates presence of required API keys and surfaces errors early.
- Minor runtime behavior and message formatting tweaks for more consistent transcripts and responses.
-
Documentation
- Updated setup and run instructions to include copying .env and installing dependencies.
-
Chores
- Added an example .env file with placeholder API keys.
✏️ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Adds a .env.example, updates README to use dotenv workflow and install dependencies, and refactors app.py to load ASSEMBLYAI, OPENAI, and ELEVENLABS API keys from environment variables while adjusting transcription lifecycle and message/audio handling.
Changes
| Cohort / File(s) | Summary |
|---|---|
Configuration & Documentation real-time-voicebot/.env.example, real-time-voicebot/README.md |
New .env.example with placeholders for ASSEMBLYAI_API_KEY, OPENAI_API_KEY, ELEVENLABS_API_KEY. README updated to instruct copying .env.example → .env, adding keys, and installing dependencies (assemblyai, openai, elevenlabs, python-dotenv). |
Runtime / Application Logic real-time-voicebot/app.py |
Loads environment via python-dotenv and reads the three API keys; validates presence and raises on missing keys. Replaces hard-coded API keys with env-driven clients. Adjusts transcription lifecycle callbacks (removed early returns in open/error/close), refines on_data handling for interim vs final transcripts, updates start_transcription param formatting, and changes generate_ai_response / generate_audio message formatting and parameter usage. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
- Areas to focus on:
- Env loading and key validation paths in
app.py - Transcription lifecycle:
on_open,on_error,on_close, andon_datachanges - Message construction passed to OpenAI and text passed to ElevenLabs
- Any runtime startup ordering changes (greeting vs transcription start)
- Env loading and key validation paths in
Poem
🐰 I found a dotfile in the glade,
Keys tucked softly in a shade,
Env whispers wake the speaking bot,
Voices bloom where secrets slot,
Hopping code — a springtime serenade! 🌿🎙️
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title directly and clearly describes the main change: moving API key configuration from hardcoded values to environment variables, which is the central objective of the changeset across all modified files. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.