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.

Jarvis controls local MP3 playback through the pygame.mixer module (Windows version). You can start, pause, resume, and stop music entirely by voice, with no need to touch the keyboard. Playback picks a track at random from your music folder each time you say “play music”, so the experience stays varied across sessions.
The Ubuntu version (Jarvis2.py) plays music using os.system() instead of pygame.mixer, and expects five tracks (music1 through music5). The Windows version (Jarvis2_4windows.py) uses pygame.mixer and expects four tracks (music1 through music4). This page documents the Windows implementation in commands.py.

Prerequisites

Before the music commands work you must configure the path to your music folder in config.ini. The folder must contain MP3 files named music1.mp3, music2.mp3, music3.mp3, and music4.mp3.
[DEFAULT]
musicpath = /home/yourname/Music/
The musicpath value must be an absolute path ending with a trailing slash (/). Relative paths and paths without a trailing slash will cause the file loader to construct an invalid filename and raise an exception.

Commands

Play music

Say “play music” to load and play a random track from your music folder.
def command_play_music():
    try:
        music_folder = config['DEFAULT']['musicPath']
        music = ("music1", "music2", "music3", "music4")
        random_music = music_folder + random.choice(music) + ".mp3"
        speak("Playing your request")
        mixer.music.load(random_music)
        mixer.music.play()
    except Exception as e:
        speak(e)
random.choice(music) picks one of the four track names, the folder path and .mp3 extension are concatenated, and mixer.music.load() + mixer.music.play() start playback. If anything goes wrong (file not found, bad path, corrupt MP3), Jarvis speaks the exception message aloud.

Pause music

Say “pause music” to pause the currently playing track without losing your position.
def command_pause_music():
    mixer.music.pause()

Unpause

Say “unpause” to resume playback from where it was paused.
def command_unpause_music():
    mixer.music.unpause()

Stop music

Say “stop music” to stop playback entirely. Unlike pause, stopping resets the track position — playing again will pick a new random track.
def command_stop_music():
    mixer.music.stop()
“stop music” and “stop” are different commands. Saying just “stop” triggers command_nothing(), which exits the entire program. Make sure to say the full phrase “stop music” when you only want to end playback.

Music file naming convention

The command_play_music() function looks for files using the tuple ("music1", "music2", "music3", "music4"). Your files must be named exactly:
music1.mp3
music2.mp3
music3.mp3
music4.mp3
All four files must be present in the configured folder. If any file is missing, mixer.music.load() will raise a FileNotFoundError and Jarvis will speak the error.
To add more tracks, extend the music tuple inside command_play_music() in commands.py. For example, to add a fifth track, rename your file music5.mp3, place it in the music folder, and change the tuple to:
music = ("music1", "music2", "music3", "music4", "music5")
No other changes are needed — random.choice() will automatically include the new entry.

Build docs developers (and LLMs) love