How ilyamiro/stewart works
Project type and purpose
• Stewart is a desktop-based, local voice assistant written in Python.
• It integrates a local speech-to-text (STT) engine (Vosk models), a local text-to-speech (TTS) engine (SileroTTS via the voicesynth library), a tree-based command dispatcher, a plugin framework for actions, a simple GUI, and an optional HTTP API for external integrations.
File structure
• Top-level application entry: main.py
• “api/”: REST or WebSocket endpoints (app.py) plus scenario and event models
• “app/”: core application bootstrap and orchestration (app/app.py)
• “audio/”:
• input/: microphone capture & STT logic (recognition.py) with embedded Vosk and Silero models
• tts/: speech synthesis logic (synthesis.py)
• “config/”: YAML configuration for languages and general parameters
• “data/”: static assets (images, sounds, constants)
• “gui/”: simple animation and UI hooks (animation.py)
• “logs/”: logging setup and initializers
• “modules/”: standalone utility modules (e.g., words2num)
• “plugins/”:
• core/: built-in actions, events and media handlers
• custom/: user-provided integrations (ADB, battery, weather, gestures, Taskwarrior, etc.)
• gpt/: ChatGPT integration
• “utils/”: shared classes (type definitions), language packs, system utilities
• “scripts/”: ancillary build/test/deployment helpers
• requirements.txt & version.txt
Extract key insights from the README
• Local-only voice models for STT and TTS
• Tree-based command handling with >99% accuracy for predefined commands
• Linux only, personal-use project
• Fast, efficient plugin-driven action execution
a. Main components
• Audio Input Capture (microphone)
• STT Engine (Vosk + Silero utils)
• Core Dispatcher (main.py → app/app.py → api.tree & api.events)
• Scenario/Command Tree (api/scenarios.py + api/tree.py)
• Plugin Framework (plugins/core, plugins/custom, plugins/gpt)
• Utility Modules (modules/words2num, utils/)
• TTS Engine (SileroTTS via audio/tts/synthesis.py)
• GUI Layer (gui/animation.py)
• API Layer (api/app.py)
• Configuration & Data Store (config/, data/)
• Logging Subsystem (logs/)
• External Services (ADB, Weather API, Taskwarrior, GPT endpoint)
b. Relationships and data flow
1. User speaks → Audio Input Capture
2. Raw audio → STT Engine → Text
3. Text → Core Dispatcher → Scenario/Command Tree
4. Command Node → Plugin Framework
– Core plugins for built-in actions (media playback, system events)
– Custom plugins for external integrations
– GPT plugin for AI responses
5. Plugin produces either:
– Action execution (e.g., shell command via utils.system)
– TTS request (text for speech synthesis)
6. Text → TTS Engine → Audio Output (speaker)
7. Throughout:
– GUI Layer receives events to drive animations/status
– API Layer exposes endpoints that invoke Core Dispatcher/Plugins
– Configuration and Data provide static parameters, language packs, model paths
– Logging Subsystem records each step
c. Architectural patterns and principles
• Layered architecture separating input, processing, output
• Plugin pattern for extensibility (core vs. custom vs. GPT)
• Tree-based command routing for clear command→handler mapping
• Single responsibility modules (words2num, utils.system, config loader)
• Local-first AI (no remote STT/TTS calls, except GPT plugin if configured)
d. Key technologies and libraries
• Python 3.11
• Vosk speech-to-text models (en, ru)
• Silero TTS (via voicesynth)
• Flask or FastAPI (if used) for API layer (api/app.py)
• PyYAML for config loading
• WebSockets or HTTP for events (api/events.py)
• Logging (Python logging module via logs/setup.py)