https://github.com/michaelnabil230/ai-voice-assistant
AI Voice Assistant
https://github.com/michaelnabil230/ai-voice-assistant
ai edge flask python text-to-speech tts voice
Last synced: 6 days ago
JSON representation
AI Voice Assistant
- Host: GitHub
- URL: https://github.com/michaelnabil230/ai-voice-assistant
- Owner: michaelnabil230
- Created: 2025-10-25T18:22:10.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-10-25T18:22:12.000Z (8 months ago)
- Last Synced: 2026-06-02T13:35:05.598Z (about 1 month ago)
- Topics: ai, edge, flask, python, text-to-speech, tts, voice
- Language: HTML
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π§ AI Voice Assistant (Flask + OpenRouter + Edge TTS)
This project is an **AI-powered voice assistant** built with **Flask**, **OpenRouter (DeepSeek)** for AI responses, and **Edge TTS** for text-to-speech synthesis.
It allows users to type a message, receive an AI-generated reply, and listen to the response in **Arabic voice** using **Microsoft Edge Text-to-Speech**.
---
## π Features
* π€ **AI Chat via OpenRouter** β integrates DeepSeek model for intelligent responses.
* π **Text-to-Speech (TTS)** β converts AI replies to Arabic speech (`ar-SA-HamedNeural`).
* π§© **Flask Web App** β lightweight backend and simple frontend for interaction.
* πΎ **Session-based chat history** β remembers previous conversation context.
* π§ **Custom System Prompt** β load behavior from `prompts/system.txt`.
---
## π§± Project Structure
```
project/
βββ app.py
βββ templates/
β βββ index.html
βββ static/
β βββ (generated audio files)
βββ prompts/
β βββ system.txt
βββ README.md
```
---
## βοΈ Requirements
* Python 3.9+
* `Flask`
* `edge-tts`
* `requests`
* `asyncio`
Install dependencies:
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
---
## π Configuration
### 1. Environment Variables
Set your **OpenRouter API key** securely in the .env:
```
OPENROUTER_API_KEY="your-openrouter-api-key"
```
### 2. Create Prompt File
Create a `prompts/system.txt` file to define the assistantβs behavior, for example:
```
You are an AI assistant speaking in Arabic, helpful and professional.
Respond naturally and clearly.
```
---
## π₯οΈ Running the App
Run the Flask server:
```bash
python app.py
```
It will start the app on:
```
http://localhost:5151
```
---
## π§ API Endpoints
### `POST /speak`
**Description:**
Takes text input, sends it to OpenRouter for AI response, and generates a speech audio file.
**Request Form Data:**
| Key | Type | Description |
| ---- | ------ | --------------- |
| text | string | User input text |
**Response JSON:**
```json
{
"reply": "AI-generated text reply",
"audio_url": "/static/abc123.wav"
}
```
---
## π§© Voice Options
To list available voices:
```bash
edge-tts --list-voices
```
Then modify this line in `app.py`:
```python
communicate = edge_tts.Communicate(ai_response, "ar-SA-HamedNeural")
```
---
## π§° Notes
* Make sure the `static/` directory exists β it stores generated `.wav` files.
* The `session` is used to store chat history per user.
* You can replace `deepseek/deepseek-chat-v3.1:free` with any other OpenRouter model.
---
## π License
MIT License Β© 2025