DEV Community

Cover image for Build Your Own Jarvis AI Assistant in Python 🚀
Bilal Aslam
Bilal Aslam

Posted on

Build Your Own Jarvis AI Assistant in Python 🚀

# Build Your Own Jarvis AI Assistant in Python 🚀

![Python](https://img.shields.io/badge/Python-3.10+-blue?style=flat-square) ![MIT License](https://img.shields.io/badge/License-MIT-green?style=flat-square)

Ever wanted your **own AI assistant** like Jarvis from Iron Man? In this blog, I’ll walk you through a Python project that listens to your voice commands, opens websites, plays music, gives you news, tells the time, and much more.  

All of this is done using Python libraries like **SpeechRecognition**, **gTTS**, **pygame**, and **OpenAI GPT API**.

---

## Features of Jarvis AI

Here’s what your assistant can do out-of-the-box:

### Web & Apps
- Open YouTube, Spotify, Facebook, Google, WhatsApp (Windows only)

### Music
- Play songs from a predefined library (`music_library.py`)

### General
- Greet you with “Hello”
- Tell today’s date and current time
- Fetch global and Pakistani news (requires API key)

> ⚠️ Commands like `Open LinkedIn` are not included by default. You can add your own commands by editing `main.py`.

---

## Getting Started

### 1. Prerequisites

- Python 3.10 or higher
- Internet connection
- Microphone for voice commands

### 2. Installation

1. **Clone the repository**:

```

bash
git clone https://github.com/your-username/Jarvis-AI-Virtual-Assistant.git
cd Jarvis-AI-Virtual-Assistant


Enter fullscreen mode Exit fullscreen mode
  1. Create a virtual environment:

bash
python -m venv .venv


Enter fullscreen mode Exit fullscreen mode
  1. Activate the virtual environment:
  • Windows (PowerShell):

powershell
& ".\\.venv\\Scripts\\Activate.ps1"


Enter fullscreen mode Exit fullscreen mode
  • Linux/macOS:

bash
source .venv/bin/activate


Enter fullscreen mode Exit fullscreen mode
  1. Install dependencies:

bash
pip install -r requirements.txt


Enter fullscreen mode Exit fullscreen mode

3. Configure API Keys

Jarvis uses OpenAI GPT API and optionally a news API:

  1. Copy config.json.example → rename it to config.json.
  2. Paste your keys:

json
{
    "OPENAI_API_KEY": "YOUR_OPENAI_KEY_HERE",
    "NEWS_API_KEY": "YOUR_NEWS_API_KEY_HERE"
}


Enter fullscreen mode Exit fullscreen mode

Do not share your API keys publicly.


4. Running Jarvis


bash
python main.py


Enter fullscreen mode Exit fullscreen mode
  • Say “Jarvis” to wake your assistant.
  • Try commands like:

    • “Open YouTube”
    • “Play Shape of You”
    • “Global news”
    • “Current time”

5. Customization

  • Add new songs in music_library.py.
  • Add new commands in main.py.
  • Extend AI responses using OpenAI GPT API.

6. Troubleshooting

  • Jarvis doesn’t hear you → check microphone settings.
  • API issues → verify keys in config.json.
  • Dependencies not installed → pip install -r requirements.txt.

Final Thoughts

This project is a fun way to learn Python, APIs, and voice interaction. It’s lightweight, fully customizable, and a great starting point for building more advanced AI assistants.

I encourage you to fork the repo, play with the code, and make your own Jarvis!


GitHub Repo: Jarvis-AI-Virtual-Assistant

License: MIT

Share it with your beginners and non-coders friend to develop their interest.

Check My Linkedin Profile: Bilal-Aslam

Top comments (0)