How ruapotato/voice-command works
Main Components
• Voice Input & Speech Processing:
• Component: speech/whisper_processor.py
• Function: Converts voice input into text using the Whisper model.
• Core Voice System:
• Component: core/voice_system.py
• Function: Manages the overall voice command processing workflow.
• Command Processing:
• Component: commands/command_processor.py
• Function: Interprets the transcribed voice command and delegates it to the correct command handler.
• Sub-components:
• commands/click_command.py – handles “Click [text]” commands using OCR-based screen text identification.
• commands/type_command.py – handles “Type [text]” commands via keyboard emulation.
• commands/read_command.py – handles “Read” commands, triggering text-to-speech.
• commands/computer_command.py – handles “Computer [query]” commands; interacts with a local LLM.
• Graphical User Interface (GUI):
• Components: gui/application.py, gui/window.py
• Function: Provides a visual interface including microphone buttons, status indicators, and basic controls for toggling continuous listening or stopping actions.
• Supporting and Entry-Point:
• main.py serves as the application’s entry point.
• Additional scripts such as print_project.py aid in debugging/printing the project structure.
Relationships and Interactions
• Input Flow:
• The speech component (whisper_processor.py) captures and processes the audio.
• Core Processing:
• The resulting text is passed to core/voice_system.py that manages overall command interpretation.
• This then calls the commands/command_processor.py, which examines the text for keywords (“Click”, “Type”, “Read”, “Computer”) and forwards control to the specific command handler in the commands directory.
• Command Execution:
• Each command handler (e.g., click_command.py, type_command.py) takes the processed command and performs dedicated operations—clicking on-screen elements, simulating keyboard actions, synthesizing speech (via external system dependencies like espeak), or querying the local LLM for “Computer” commands.
• GUI Feedback:
• Throughout this process, the GUI components (in gui/application.py and gui/window.py) display system status, allow toggling of modes, and provide user feedback regarding command actions.
Architectural Patterns and Design Principles
• Modularity: The project is split into separate modules (speech, core, commands, gui) that each focus on a distinct aspect of the system.
• Separation of Concerns (SoC): Voice processing, command interpretation, and GUI are completely separated to keep the system maintainable.
• Extensibility: New command handlers can be added easily in the commands/ directory following a similar design pattern.
Important Technologies and External Dependencies
• Python libraries (as listed in requirements.txt) for interfacing with system commands and handling voice/GUI interactions.
• OpenAI’s Whisper model for speech recognition.
• Local LLM integration via Ollama for natural language queries.
• External command-line tools: xdotool (for interacting with GUI elements), espeak (for text-to-speech), xclip and tesseract-ocr (for OCR functionality).