Skip to content

Repository files navigation

๐ŸŽ™๏ธ AI Voice Assistant โ€“ Flask App

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.


๐Ÿง  Key Features

  • ๐ŸŽค 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โ€.

๐Ÿ“ Project Structure

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


๐Ÿš€ Getting Started

1. Clone the repository

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
---

About

๐ŸŽ™๏ธ InstructBot โ€“ A voice-controlled AI assistant built with Flask. Listens to your commands, decides if theyโ€™re system tasks or questions, executes or responds intelligently, and speaks back in real-time.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages