A smart voice assistant web application built with Flask that listens to user speech, interprets the command using AI, and performs system tasks or responds with natural language. The assistant speaks the response back and provides real-time feedback on the interface.
- ๐ค Voice Input: Capture user voice commands through the browser.
- ๐ง AI-Powered Interpretation: Uses
ask_instructbot()to decide if a command is a system task or general question. - ๐ ๏ธ System Task Execution: Executes commands like opening apps, fetching system info, etc.
- ๐ฌ Natural Language Replies: Responds using intelligent AI-generated replies when no system task is needed.
- ๐ Text-to-Speech Output: Speaks the response aloud using the systemโs TTS engine.
- ๐ฅ๏ธ Responsive Frontend: Real-time status updates like โListeningโฆโ, โThinkingโฆโ, and โStoppedโ.
instructbot/ โโโ app.py # Main Flask app โโโ config.py # SAFE_MODE and other settings โโโ speech_to_text.py # Microphone input and speech recognition โโโ text_to_speech.py # Text-to-speech conversion โโโ ai_response.py # AI decision logic (chat vs system task) โโโ system_actions.py # Executes commands (e.g., open apps) โโโ templates/ โ โโโ index.html # Frontend UI with buttons and status โโโ static/ โ โโโ style.css # (Optional) UI styling โโโ README.md # Youโre here!
yaml Copy Edit
git clone https://github.com/Divyansh723/InstructBot.git
cd instructbot
2. Create virtual environment and install dependencies
bash
Copy
Edit
python -m venv venv
source venv/bin/activate pip install -r requirements.txt
3. Set environment variables
Create a .env or setin config.py:
python
Copy
Edit
SAFE_MODE = True 4. Run the app
bash
Copy
Edit
python app.py
Then open http://localhost:5000 in your browser.
๐งช Example Workflow
Press Start Listening
Say: โOpen Notepadโ or โWhat is the weather?โ
The assistant will:
Listen to your voice
Use ask_instructbot() to decide the intent
If itโs a system command, it runs run_system_task()
Otherwise, replies using AI
Finally, speaks the result out loud
๐ง API Endpoints
Method Endpoint Description
POST /start_listening Begins speech recognition, sends command to AI and executes
POST /stop_listening Stops the assistant
GET / Loads the HTML interface
๐ Dependencies
Flask
SpeechRecognition
pyttsx3 (Text-to-speech)
OpenAI / Gemini API (optional for AI replies)
OS libraries for system commands
Install via:
bash
Copy
Edit
pip install Flask SpeechRecognition pyttsx3
โ ๏ธ Safety Notes
If SAFE_MODE = False, system commands will execute directly โ use caution.
AI response models should be sandboxed if connected to powerful tools.
##๐ License
This project is open-source and available under the MIT License.
---
##๐โโ๏ธ Author
Made with โค๏ธ by Divyansh
---