Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Harsha200105/DesktopAssistant/llms.txt

Use this file to discover all available pages before exploring further.

Getting a local development environment running for Desktop Assistant is straightforward. The project is a pure-Python application, so all you need is a compatible Python interpreter, a virtual environment, and the platform-specific dependency list provided in the repository. This page covers every step from forking the repo to running Jarvis in text-input (debug) mode so you can iterate on new commands without needing a microphone attached.

Prerequisites

Before you begin, make sure the following are available on your machine:
  • Python 3.9 or later — the project’s Ubuntu dependency snapshot was built against Python 3.9.7. Run python --version to check.
  • git — needed to clone the repository and manage branches.
  • A microphone (optional for development) — Jarvis uses speech_recognition to capture voice input. Set debug = True in config.ini to bypass the microphone entirely and type commands instead.
On Ubuntu you also need the system libraries portaudio19-dev and espeak before installing Python packages. The commands are shown in the setup steps below.

Setting Up Your Environment

1

Fork and clone the repository

Fork the repository on GitHub, then clone your fork:
git clone https://github.com/YOUR-USERNAME/DesktopAssistant.git
cd DesktopAssistant
If you plan to contribute back, also add the upstream remote:
git remote add upstream https://github.com/Harsha200105/DesktopAssistant.git
2

Create and activate a virtual environment

Create a virtual environment inside the repository root so your system Python is not affected:
python -m venv venv
Then activate it for your platform:
venv\Scripts\activate
Your terminal prompt will be prefixed with (venv) once the environment is active.
3

Install dependencies

The repository ships two requirements files — one per platform.
pip install --upgrade pip
pip install -r "Requirements&COC/requirements.txt"
The Windows requirements file installs:
pygame==2.0.1
SpeechRecognition==3.8.1
wikipedia==1.4.0
PyAudio==0.2.11
pyttsx3==2.90
tk
4

Copy config.ini into the src/ directory

Jarvis reads config.ini from the current working directory at startup (see the os.path.isfile('./config.ini') check at the bottom of src/Jarvis2_4windows.py). Copy the template and then edit it:
cp "Requirements&COC/config.ini" src/config.ini
Open src/config.ini and fill in your details:
[DEFAULT]
master = YourName
search_engine = Google
debug = False
musicpath =
voice = Male
rate = 150
volume = 100
energy_threshold = 300

[EMAIL]
server = smtp.gmail.com
port = 587
username =
password =
Key settings:
KeyDescription
masterThe name Jarvis uses when greeting you
search_engineGoogle, Bing, DuckDuckGo, or Youtube
debugSet to True to use keyboard input instead of the microphone
musicpathAbsolute path to a folder containing music1.mp3music4.mp3
voiceMale or Female — maps to the first or second pyttsx3 voice
rateSpeech rate in words per minute (default 150)
volumeVolume as a percentage from 0 to 100 (default 100)
energy_thresholdMicrophone sensitivity; increase if Jarvis misses commands
5

Run Jarvis in debug mode

With debug = True in config.ini, Jarvis replaces the microphone with a simple input() prompt. This lets you test command routing without any audio hardware.
cd src
python Jarvis2_4windows.py   # Windows
# or
python Jarvis2.py            # Ubuntu
The Tkinter window will open and you will see the Command |--> prompt in your terminal. Type a command (e.g., wikipedia Python programming language) and press Enter to see Jarvis respond.

Code Structure

The project is intentionally lean — most logic lives in four Python files under src/:

src/Jarvis2_4windows.py

Windows entry point. Contains run() (reads config.ini, builds the take_command closure, calls wish_me) and main() (holds the phrases dict for zero-argument commands and the execute_the_command_said_by_user inner function for argument-bearing commands). This is the file to edit when wiring in a new command.

src/Jarvis2.py

Ubuntu entry point. A self-contained monolithic script that inlines speak, wish_me, take_command, and execute_the_command_said_by_user without importing from commands.py or actions.py. Useful as a reference for the expected end-to-end behaviour of each command.

src/commands.py

Individual command handlers. Each public function handles one user intent. Current handlers: command_wikipedia, command_whatsup, command_open, command_search, command_mail, command_nothing, command_hello, command_bye, command_play_music, command_pause_music, command_stop_music, command_unpause_music. New commands belong here.

src/actions.py

Core utilities shared across commands. Exports: speak(text), wish_me(master), open_url(url), search(search_query, search_engine), search_engine_selector(config), change_rate(query, take_command), change_voice(query, take_command), change_volume(query, take_command), set_gui_speak(command). The pyttsx3 engine is initialised at module level.

src/gui.py

Tkinter GUI. Builds a 700 × 500 root window with a scrollable Listbox that displays assistant responses and a Speak button wired to execute_the_command_said_by_user. The speak(text) function here appends Assistant: <text> to the listbox. mainloop is the Tkinter root.mainloop function re-exported for use by the entry points.

Requirements&COC/

Config and dependency files. config.ini — settings template; requirements.txt — Windows pip dependencies; ubuntu_requirements.txt — Ubuntu pip dependencies (also documents required system packages as comments).

Adding a New Command

Adding a voice command to Jarvis takes two steps: implement the handler in commands.py, then register the trigger phrase in Jarvis2_4windows.py.

1. Implement the handler in src/commands.py

Follow the existing pattern. Zero-argument commands accept no parameters; commands that need user input accept query and/or take_command (and optionally debug):
# src/commands.py

def command_joke():
    """Tell a random pre-written joke."""
    jokes = [
        "Why do programmers prefer dark mode? Because light attracts bugs.",
        "I told my computer I needed a break. Now it won't stop sending me Kit-Kat ads.",
    ]
    speak(random.choice(jokes))
For commands that need to search or open URLs, import and call the helpers from actions.py:
from actions import open_url, search, speak

2. Wire the phrase in src/Jarvis2_4windows.py

Zero-argument commands — add an entry to the phrases dict inside execute_the_command_said_by_user:
phrases = {
    "what's up":    command_whatsup,
    "nothing":      command_nothing,
    "abort":        command_nothing,
    "stop":         command_nothing,
    "hello":        command_hello,
    "bye":          command_bye,
    "play music":   command_play_music,
    "unpause":      command_unpause_music,
    "pause music":  command_pause_music,
    "stop music":   command_stop_music,
    "tell me a joke": command_joke,   # ← new entry
}
Also add the import at the top of the file:
from commands import (  # isort: skip
    ...
    command_joke,
)
Commands that need the query string — add an elif branch in the same function, after the phrases loop:
elif "joke" in query:
    command_joke()
Run Jarvis with debug = True after adding your command. Type the trigger phrase at the Command |--> prompt to verify routing before testing with microphone input.

Linting

The CI pipeline (.github/workflows/lint_python.yml) runs flake8 with a maximum line length of 88 and maximum cyclomatic complexity of 19. Run the same check locally before pushing:
flake8 src/ --count --max-complexity=19 --max-line-length=88 --show-source --statistics
The pipeline also runs bandit for security issues, isort for import ordering, codespell for typos, and mypy for type checking. Install them all at once:
pip install bandit black codespell flake8 flake8-bugbear flake8-comprehensions \
            flake8-return isort mypy pep8-naming pyupgrade safety
pyttsx3 initialises the sapi5 speech engine at import time on Windows (engine = pyttsx3.init("sapi5")). If you are running the CI linting steps on a Linux machine (as the workflow does), import errors from actions.py are expected and are handled by the --ignore-missing-imports flag passed to mypy.

Build docs developers (and LLMs) love