How kaymen99/ai-voice-assistant works
Project Type and Purpose
• This is a monolithic Python-based AI Voice Assistant application.
• It provides a command-line (or local) conversational interface using Speech-to-Text (STT) and Text-to-Speech (TTS), powered by large language models (Llama3 via Groq API or Gemini) and a suite of “tools” to manage calendars, contacts, emails, web searches, and a personal knowledge base.
High-Level Architecture Overview
• Input Layer: Captures user speech via microphone.
• Processing Layer:
• STT module converts audio → text.
• Conversation Manager orchestrates context, history, and tool selection.
• Agent core (in src/agents/agent.py) calls the LLM with prompts (managed in src/prompts/prompts.py).
• Tool Executor dispatches calls to individual tools (in src/tools/*).
• External Services Layer:
• Deepgram (voice processing)
• Google APIs (Calendar, Contacts, Gmail)
• Tavily Search API
• Groq API / Gemini API (LLM model)
• Local files/embeddings index for KnowledgeBaseTool
• Output Layer: TTS module converts text → speech, played back to the user.
Main Components & Relationships
• User Interface (microphone & speaker)
→ feeds audio into
• STT Subsystem (src/speech_processing/speech_to_text.py)
→ outputs text to
• Conversation Manager (src/speech_processing/conversation_manager.py)
↔ maintains context with
• Agent Core (src/agents/agent.py)
→ uses Prompt Manager (src/prompts/prompts.py) to build LLM queries
→ calls LLM via Groq/Gemini API
→ inspects LLM response for tool invocation
• Tool Executor (base class in src/tools/base_tool.py)
→ dispatches to specific tool modules:
• CalendarTool
• AddContactTool / FetchContactTool
• EmailingTool
• SearchWebTool
• KnowledgeBaseTool (backed by the index created/fetched by scripts/create_index.py & scripts/fetch_index.py)
→ each tool calls its respective external API (Google, Tavily, local storage)
→ returns structured result to Agent
• Agent Core
→ forwards final text response to
• TTS Subsystem (src/speech_processing/text_to_speech.py)
→ plays synthesized audio to user
Important Architectural Patterns & Principles
• Layered design (Input → Core Logic → Integration → Output)
• Plugin-like “Tool” architecture: each tool implements a common interface (BaseTool), enabling easy extension.
• Separation of concerns: STT/TTS, dialogue management, LLM orchestration, and external integrations are decoupled into distinct modules.
• Asynchronous I/O (if implemented) for non-blocking API calls (optional).
Essential Elements Checklist
• Component labels matching code modules (e.g., ConversationManager, PromptManager).
• A note or callout showing where environment variables (API keys) are injected.