How gurunesh30/voice-agent works
Purpose and Entry Points
This repository implements a Python voice assistant for microphone-driven commands, speech output, and optional internet/email integrations. The documented runtime entry point is main.py; it instantiates and runs the assistant core in src/voice_assistant.py. A separate Vite/Bun-compatible frontend exists, with browser entry frontend/src/main.jsx, but no backend/web bridge is evident from the supplied tree.
Assistant Orchestration
src/voice_assistant.py is the control-plane class: it manages interaction lifecycle, mode selection (beginner versus advanced), command interpretation, dispatch, and user-facing responses. main.py is the CLI bootstrap boundary. The assistant is intended to register command handlers rather than embedding each integration directly.
• main.py
• src/voice_assistant.py
• src/commands/__init__.py
Speech I/O Boundary
Speech capture, Google-backed speech-to-text, ambient-noise handling, recognition failure handling, and text-to-speech are centralized behind the speech utility. The core assistant should consume recognized text and emit response text through this boundary, isolating audio-device and recognition-provider concerns from command logic.
• src/utils/speech.py
• src/voice_assistant.py
Command Processing Layers
Basic commands handle local, deterministic intents such as greetings, time/date/day, help, thanks, and exit. Advanced commands extend that surface with query extraction and remote/task-oriented operations. The assistant dispatches normalized recognized text to these modules according to selected mode; advanced mode includes basic behavior.
• src/commands/basic_commands.py
• src/commands/advanced_commands.py
• src/voice_assistant.py
External Services and Side Effects
Advanced handlers form the integration boundary for web search, OpenWeather lookups, joke APIs, and Gmail SMTP email delivery. These paths require network access; weather and email depend on credentials/settings. Email is the highest-impact side effect and should remain explicitly invoked rather than inferred from arbitrary recognition text.
• src/commands/advanced_commands.py
• config/settings.json
• src/utils/helpers.py
Configuration, Logging, and Runtime
Configuration holds API keys and user preferences, keeping credentials outside command source. Logging captures interactions and operational failures, with the README indicating logs are created at runtime. Python 3.7+ and dependencies from requirements.txt provide the primary execution environment.
• config/settings.json
• src/utils/logger.py
• requirements.txt
Optional Visual Frontend
The frontend is an independent React/Vite interface styled as an assistant console, with visual/audio/transcript components and a WebSocket hook. It appears architecturally separate from the Python CLI because no server or WebSocket endpoint is present in the listed Python files; integration would require a new transport/API layer.
• frontend/src/App.jsx
• frontend/src/hooks/useWebSocket.js
• frontend/src/components/AssistantContext.jsx
Main entry points: voice_assistant.py Assistant Core · advanced_commands.py Advanced Commands · __init__.py Command Registry · App.jsx Assistant Console
Components 15
Python Assistant
Microphone-driven CLI runtime.
- CLI Bootstrap
main.py - Assistant Core · Selects modes, interprets input, dispatches commands, and responds.
src/voice_assistant.py - Speech I/O · Microphone capture, speech recognition, and text-to-speech boundary.
src/utils/speech.py - Command Registry
src/commands/__init__.py - Basic Commands · Greetings, date/time, help, thanks, and exit.
src/commands/basic_commands.py - Advanced Commands · Extends basic behavior with queries and remote tasks.
src/commands/advanced_commands.py - Integration Helpers
src/utils/helpers.py - Settings · API keys and user preferences.
config/settings.json - Runtime Logging · Records interactions and operational failures.
src/utils/logger.py - Python Dependencies
requirements.txt
External Integrations
Network and credential-backed operations.
- Web, Weather, Joke & Gmail · Network APIs plus explicitly invoked SMTP email delivery.
Optional Frontend
Standalone Vite/Bun-compatible UI with no shown backend bridge.
- Assistant Console
frontend/src/App.jsx - WebSocket Hook · No corresponding Python endpoint is evident.
frontend/src/hooks/useWebSocket.js - Assistant Context · Provides visual, audio, and transcript state to UI components.
frontend/src/components/AssistantContext.jsx - Browser Entry
frontend/src/main.jsx
Connections 16
- CLI Bootstrap → Assistant Core: starts
- Assistant Core → Speech I/O: listens / speaks
- Assistant Core → Command Registry: loads handlers
- Command Registry → Basic Commands: registers
- Command Registry → Advanced Commands: registers
- Assistant Core → Basic Commands: beginner dispatch
- Assistant Core → Advanced Commands: advanced dispatch
- Advanced Commands → Integration Helpers: uses
- Advanced Commands → Settings: reads credentials
- Integration Helpers → Web, Weather, Joke & Gmail: calls
- Assistant Core → Runtime Logging: logs lifecycle
- Python Dependencies → Assistant Core: provides runtime packages
- Browser Entry → Assistant Console: mounts
- Assistant Console → Assistant Context: consumes state
- Assistant Console → WebSocket Hook: uses transport
- WebSocket Hook → Assistant Core: no endpoint shown · A transport/API layer would be required for integration.