Spaces:
Runtime error
Runtime error
jawaduddin commited on
Commit ·
e2d93fe
1
Parent(s): b861707
Fix frontend raw code display, support x-api-key, and cleanup project
Browse files- .github/workflows/deploy_to_hf.yml +0 -25
- QUICKSTART.md +0 -231
- backend/.env.example +0 -10
- backend/main.py +18 -7
- backend/setup_firebase.py +0 -137
- backend/test_flow.py +0 -120
- datasets/numpy_datasets/generate_dataset.py +0 -167
- frontend/index.html +69 -54
- frontend/register.html +106 -89
- render.yaml +0 -24
- secret.txt +0 -1
- setup.sh +0 -97
- upload_to_hf.py +0 -59
.github/workflows/deploy_to_hf.yml
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
name: Sync to Hugging Face Hub
|
| 2 |
-
|
| 3 |
-
on:
|
| 4 |
-
push:
|
| 5 |
-
branches: [main]
|
| 6 |
-
workflow_dispatch:
|
| 7 |
-
|
| 8 |
-
jobs:
|
| 9 |
-
sync-to-hub:
|
| 10 |
-
runs-on: ubuntu-latest
|
| 11 |
-
steps:
|
| 12 |
-
- uses: actions/checkout@v3
|
| 13 |
-
|
| 14 |
-
- name: Set up Python
|
| 15 |
-
uses: actions/setup-python@v4
|
| 16 |
-
with:
|
| 17 |
-
python-version: '3.9'
|
| 18 |
-
|
| 19 |
-
- name: Install dependencies
|
| 20 |
-
run: pip install huggingface_hub
|
| 21 |
-
|
| 22 |
-
- name: Run Upload Script
|
| 23 |
-
env:
|
| 24 |
-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 25 |
-
run: python upload_to_hf.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QUICKSTART.md
DELETED
|
@@ -1,231 +0,0 @@
|
|
| 1 |
-
# Quick Start Guide
|
| 2 |
-
|
| 3 |
-
## Prerequisites Checklist
|
| 4 |
-
|
| 5 |
-
Before running the setup, ensure you have:
|
| 6 |
-
|
| 7 |
-
- [ ] **Python 3.8+** installed (`python3 --version`)
|
| 8 |
-
- [ ] **FFmpeg** installed (required for audio processing)
|
| 9 |
-
- macOS: `brew install ffmpeg`
|
| 10 |
-
- Ubuntu: `sudo apt-get install ffmpeg`
|
| 11 |
-
- [ ] **MongoDB** running (local or Atlas URI ready)
|
| 12 |
-
|
| 13 |
-
## Automated Setup (Recommended)
|
| 14 |
-
|
| 15 |
-
Run the automated setup script:
|
| 16 |
-
|
| 17 |
-
```bash
|
| 18 |
-
cd "Guvi Hackathon"
|
| 19 |
-
./setup.sh
|
| 20 |
-
```
|
| 21 |
-
|
| 22 |
-
This will:
|
| 23 |
-
1. Create virtual environment
|
| 24 |
-
2. Install all dependencies
|
| 25 |
-
3. Generate training dataset
|
| 26 |
-
4. Train the ML model
|
| 27 |
-
5. Set up environment files
|
| 28 |
-
|
| 29 |
-
## Manual Setup
|
| 30 |
-
|
| 31 |
-
If you prefer manual setup:
|
| 32 |
-
|
| 33 |
-
### 1. Install Dependencies
|
| 34 |
-
|
| 35 |
-
```bash
|
| 36 |
-
cd backend
|
| 37 |
-
python3 -m venv venv
|
| 38 |
-
source venv/bin/activate # On Windows: venv\Scripts\activate
|
| 39 |
-
pip install -r requirements.txt
|
| 40 |
-
```
|
| 41 |
-
|
| 42 |
-
### 2. Configure Environment
|
| 43 |
-
|
| 44 |
-
```bash
|
| 45 |
-
cp .env.example .env
|
| 46 |
-
# Edit .env and set:
|
| 47 |
-
# - API_KEY=your-secret-key
|
| 48 |
-
# - MONGODB_URI=mongodb://localhost:27017/
|
| 49 |
-
```
|
| 50 |
-
|
| 51 |
-
### 3. Generate Dataset
|
| 52 |
-
|
| 53 |
-
```bash
|
| 54 |
-
cd ../datasets/numpy_datasets
|
| 55 |
-
python3 generate_dataset.py
|
| 56 |
-
```
|
| 57 |
-
|
| 58 |
-
### 4. Train Model
|
| 59 |
-
|
| 60 |
-
```bash
|
| 61 |
-
cd ../../backend
|
| 62 |
-
python3 model/train_model.py
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
-
### 5. Start Backend
|
| 66 |
-
|
| 67 |
-
```bash
|
| 68 |
-
uvicorn main:app --reload
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
-
Backend runs at: `http://localhost:8000`
|
| 72 |
-
|
| 73 |
-
### 6. Open Frontend
|
| 74 |
-
|
| 75 |
-
Open `frontend/index.html` in your browser, or:
|
| 76 |
-
|
| 77 |
-
```bash
|
| 78 |
-
cd ../frontend
|
| 79 |
-
python3 -m http.server 8080
|
| 80 |
-
```
|
| 81 |
-
|
| 82 |
-
Frontend runs at: `http://localhost:8080`
|
| 83 |
-
|
| 84 |
-
## Configuration
|
| 85 |
-
|
| 86 |
-
### API Key
|
| 87 |
-
|
| 88 |
-
Set in `backend/.env`:
|
| 89 |
-
```
|
| 90 |
-
API_KEY=your-secret-api-key-here
|
| 91 |
-
```
|
| 92 |
-
|
| 93 |
-
Update in `frontend/script.js`:
|
| 94 |
-
```javascript
|
| 95 |
-
const API_KEY = 'your-secret-api-key-here';
|
| 96 |
-
```
|
| 97 |
-
|
| 98 |
-
### MongoDB
|
| 99 |
-
|
| 100 |
-
**Local MongoDB:**
|
| 101 |
-
```
|
| 102 |
-
MONGODB_URI=mongodb://localhost:27017/
|
| 103 |
-
```
|
| 104 |
-
|
| 105 |
-
**MongoDB Atlas:**
|
| 106 |
-
```
|
| 107 |
-
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/
|
| 108 |
-
```
|
| 109 |
-
|
| 110 |
-
### API Base URL
|
| 111 |
-
|
| 112 |
-
For production, update in `frontend/script.js`:
|
| 113 |
-
```javascript
|
| 114 |
-
const API_BASE_URL = 'https://your-api-domain.com';
|
| 115 |
-
```
|
| 116 |
-
|
| 117 |
-
## Testing the System
|
| 118 |
-
|
| 119 |
-
### 1. Test API Health
|
| 120 |
-
|
| 121 |
-
```bash
|
| 122 |
-
curl http://localhost:8000/
|
| 123 |
-
```
|
| 124 |
-
|
| 125 |
-
Expected response:
|
| 126 |
-
```json
|
| 127 |
-
{
|
| 128 |
-
"status": "online",
|
| 129 |
-
"service": "AI Voice Detection API",
|
| 130 |
-
"version": "1.0.0"
|
| 131 |
-
}
|
| 132 |
-
```
|
| 133 |
-
|
| 134 |
-
### 2. Test Voice Detection
|
| 135 |
-
|
| 136 |
-
```bash
|
| 137 |
-
# Convert sample MP3 to base64
|
| 138 |
-
base64_audio=$(base64 -i sample.mp3)
|
| 139 |
-
|
| 140 |
-
# Make API request
|
| 141 |
-
curl -X POST http://localhost:8000/detect-voice \
|
| 142 |
-
-H "Authorization: Bearer your-secret-api-key-here" \
|
| 143 |
-
-H "Content-Type: application/json" \
|
| 144 |
-
-d "{\"audio_base64\": \"$base64_audio\"}"
|
| 145 |
-
```
|
| 146 |
-
|
| 147 |
-
### 3. Test Frontend
|
| 148 |
-
|
| 149 |
-
1. Open `http://localhost:8080` (or open `index.html`)
|
| 150 |
-
2. Click "Upload Audio File"
|
| 151 |
-
3. Select an MP3 file
|
| 152 |
-
4. Click "Analyze Voice"
|
| 153 |
-
5. View results
|
| 154 |
-
|
| 155 |
-
## Troubleshooting
|
| 156 |
-
|
| 157 |
-
### FFmpeg Not Found
|
| 158 |
-
|
| 159 |
-
**Error:** `FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'`
|
| 160 |
-
|
| 161 |
-
**Solution:**
|
| 162 |
-
```bash
|
| 163 |
-
# macOS
|
| 164 |
-
brew install ffmpeg
|
| 165 |
-
|
| 166 |
-
# Ubuntu/Debian
|
| 167 |
-
sudo apt-get install ffmpeg
|
| 168 |
-
```
|
| 169 |
-
|
| 170 |
-
### MongoDB Connection Failed
|
| 171 |
-
|
| 172 |
-
**Error:** `Failed to connect to MongoDB`
|
| 173 |
-
|
| 174 |
-
**Solution:**
|
| 175 |
-
- Ensure MongoDB is running: `brew services start mongodb-community` (macOS)
|
| 176 |
-
- Or use MongoDB Atlas and update `MONGODB_URI` in `.env`
|
| 177 |
-
|
| 178 |
-
### Model Not Found
|
| 179 |
-
|
| 180 |
-
**Error:** `Model files not found`
|
| 181 |
-
|
| 182 |
-
**Solution:**
|
| 183 |
-
```bash
|
| 184 |
-
cd backend
|
| 185 |
-
python3 model/train_model.py
|
| 186 |
-
```
|
| 187 |
-
|
| 188 |
-
### CORS Errors
|
| 189 |
-
|
| 190 |
-
**Error:** `CORS policy: No 'Access-Control-Allow-Origin'`
|
| 191 |
-
|
| 192 |
-
**Solution:**
|
| 193 |
-
- Use `python3 -m http.server` to serve frontend
|
| 194 |
-
- Or configure CORS in `backend/main.py` for your domain
|
| 195 |
-
|
| 196 |
-
## Project Structure
|
| 197 |
-
|
| 198 |
-
```
|
| 199 |
-
Guvi Hackathon/
|
| 200 |
-
├── backend/ # FastAPI backend
|
| 201 |
-
│ ├── main.py # API application
|
| 202 |
-
│ ├── model/ # ML model files
|
| 203 |
-
│ ├── utils/ # Utilities
|
| 204 |
-
│ └── requirements.txt
|
| 205 |
-
├── frontend/ # Web interface
|
| 206 |
-
│ ├── index.html # Landing page
|
| 207 |
-
│ ├── upload.html # Upload page
|
| 208 |
-
│ ├── result.html # Results page
|
| 209 |
-
│ ├── styles.css # Styling
|
| 210 |
-
│ └── script.js # Frontend logic
|
| 211 |
-
├── datasets/ # Training data
|
| 212 |
-
└── README.md # Full documentation
|
| 213 |
-
```
|
| 214 |
-
|
| 215 |
-
## Next Steps
|
| 216 |
-
|
| 217 |
-
1. ✅ Complete setup
|
| 218 |
-
2. ✅ Test the system
|
| 219 |
-
3. 📝 Customize API key
|
| 220 |
-
4. 🚀 Deploy to production (see README.md)
|
| 221 |
-
5. 🎯 Present at hackathon!
|
| 222 |
-
|
| 223 |
-
## Support
|
| 224 |
-
|
| 225 |
-
For detailed documentation, see [README.md](README.md)
|
| 226 |
-
|
| 227 |
-
For issues, check the troubleshooting section above.
|
| 228 |
-
|
| 229 |
-
---
|
| 230 |
-
|
| 231 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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/.env.example
DELETED
|
@@ -1,10 +0,0 @@
|
|
| 1 |
-
# Environment Variables Template
|
| 2 |
-
# Copy this file to .env and fill in your values
|
| 3 |
-
|
| 4 |
-
# API Key for authentication
|
| 5 |
-
API_KEY=your-secret-api-key-here
|
| 6 |
-
|
| 7 |
-
# MongoDB Connection URI
|
| 8 |
-
# Local: mongodb://localhost:27017/
|
| 9 |
-
# Atlas: mongodb+srv://username:password@cluster.mongodb.net/
|
| 10 |
-
MONGODB_URI=mongodb://localhost:27017/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/main.py
CHANGED
|
@@ -62,7 +62,14 @@ explainer = VoiceExplainer()
|
|
| 62 |
# Request/Response models
|
| 63 |
class VoiceDetectionRequest(BaseModel):
|
| 64 |
"""Request model for voice detection"""
|
| 65 |
-
audio_base64: str = Field(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
|
| 68 |
class ExplanationModel(BaseModel):
|
|
@@ -233,6 +240,7 @@ async def root():
|
|
| 233 |
def detect_voice(
|
| 234 |
request: VoiceDetectionRequest,
|
| 235 |
api_key: str = Header(None),
|
|
|
|
| 236 |
authorization: str = Header(None)
|
| 237 |
):
|
| 238 |
"""
|
|
@@ -269,12 +277,12 @@ def detect_voice(
|
|
| 269 |
)
|
| 270 |
user_id = str(user['_id']) # Assuming _id is ObjectId and needs conversion
|
| 271 |
|
| 272 |
-
elif api_key:
|
| 273 |
# Check legacy API Key or user specific API Key
|
| 274 |
-
|
| 275 |
-
if
|
| 276 |
# Check if it's a user-specific API key
|
| 277 |
-
user = db_manager.get_user_by_api_key(
|
| 278 |
if not user:
|
| 279 |
raise HTTPException(
|
| 280 |
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
@@ -291,7 +299,10 @@ def detect_voice(
|
|
| 291 |
|
| 292 |
logger.info(f"Received voice detection request from user: {user_email}")
|
| 293 |
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
| 295 |
raise HTTPException(
|
| 296 |
status_code=status.HTTP_400_BAD_REQUEST,
|
| 297 |
detail=create_error_response("MISSING_AUDIO")
|
|
@@ -299,7 +310,7 @@ def detect_voice(
|
|
| 299 |
|
| 300 |
# Step 1: Process audio
|
| 301 |
logger.info("Processing audio...")
|
| 302 |
-
audio, sr = audio_processor.process_base64_audio(
|
| 303 |
|
| 304 |
# Step 2: Extract features
|
| 305 |
logger.info("Extracting features...")
|
|
|
|
| 62 |
# Request/Response models
|
| 63 |
class VoiceDetectionRequest(BaseModel):
|
| 64 |
"""Request model for voice detection"""
|
| 65 |
+
audio_base64: Optional[str] = Field(None, description="Base64 encoded audio", alias="audio_base64")
|
| 66 |
+
audio_base64_format: Optional[str] = Field(None, description="Guvi tester field for base64 audio", alias="Audio Base64 Format")
|
| 67 |
+
language: Optional[str] = Field(None, alias="Language")
|
| 68 |
+
audio_format: Optional[str] = Field(None, alias="Audio Format")
|
| 69 |
+
|
| 70 |
+
class Config:
|
| 71 |
+
allow_population_by_field_name = True
|
| 72 |
+
extra = "allow"
|
| 73 |
|
| 74 |
|
| 75 |
class ExplanationModel(BaseModel):
|
|
|
|
| 240 |
def detect_voice(
|
| 241 |
request: VoiceDetectionRequest,
|
| 242 |
api_key: str = Header(None),
|
| 243 |
+
x_api_key: str = Header(None),
|
| 244 |
authorization: str = Header(None)
|
| 245 |
):
|
| 246 |
"""
|
|
|
|
| 277 |
)
|
| 278 |
user_id = str(user['_id']) # Assuming _id is ObjectId and needs conversion
|
| 279 |
|
| 280 |
+
elif api_key or x_api_key:
|
| 281 |
# Check legacy API Key or user specific API Key
|
| 282 |
+
effective_key = api_key or x_api_key
|
| 283 |
+
if effective_key != API_KEY:
|
| 284 |
# Check if it's a user-specific API key
|
| 285 |
+
user = db_manager.get_user_by_api_key(effective_key)
|
| 286 |
if not user:
|
| 287 |
raise HTTPException(
|
| 288 |
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
|
|
| 299 |
|
| 300 |
logger.info(f"Received voice detection request from user: {user_email}")
|
| 301 |
|
| 302 |
+
# Get audio data from multiple possible field names
|
| 303 |
+
audio_data = request.audio_base64 or request.audio_base64_format
|
| 304 |
+
|
| 305 |
+
if not audio_data:
|
| 306 |
raise HTTPException(
|
| 307 |
status_code=status.HTTP_400_BAD_REQUEST,
|
| 308 |
detail=create_error_response("MISSING_AUDIO")
|
|
|
|
| 310 |
|
| 311 |
# Step 1: Process audio
|
| 312 |
logger.info("Processing audio...")
|
| 313 |
+
audio, sr = audio_processor.process_base64_audio(audio_data)
|
| 314 |
|
| 315 |
# Step 2: Extract features
|
| 316 |
logger.info("Extracting features...")
|
backend/setup_firebase.py
DELETED
|
@@ -1,137 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Quick Setup Script for Firebase Migration
|
| 3 |
-
Run this after setting up Firebase project and downloading credentials
|
| 4 |
-
"""
|
| 5 |
-
|
| 6 |
-
import os
|
| 7 |
-
import sys
|
| 8 |
-
|
| 9 |
-
def check_firebase_credentials():
|
| 10 |
-
"""Check if Firebase credentials file exists"""
|
| 11 |
-
cred_path = os.path.join(os.path.dirname(__file__), 'firebase-credentials.json')
|
| 12 |
-
|
| 13 |
-
if not os.path.exists(cred_path):
|
| 14 |
-
print("❌ Firebase credentials file not found!")
|
| 15 |
-
print(f" Expected location: {cred_path}")
|
| 16 |
-
print("\n📝 Steps to fix:")
|
| 17 |
-
print(" 1. Go to Firebase Console → Project Settings → Service Accounts")
|
| 18 |
-
print(" 2. Click 'Generate new private key'")
|
| 19 |
-
print(" 3. Save the downloaded JSON file as 'firebase-credentials.json'")
|
| 20 |
-
print(f" 4. Move it to: {os.path.dirname(__file__)}/")
|
| 21 |
-
return False
|
| 22 |
-
|
| 23 |
-
print("✅ Firebase credentials file found")
|
| 24 |
-
return True
|
| 25 |
-
|
| 26 |
-
def check_env_file():
|
| 27 |
-
"""Check if .env file has Firebase configuration"""
|
| 28 |
-
env_path = os.path.join(os.path.dirname(__file__), '.env')
|
| 29 |
-
|
| 30 |
-
if not os.path.exists(env_path):
|
| 31 |
-
print("❌ .env file not found!")
|
| 32 |
-
return False
|
| 33 |
-
|
| 34 |
-
with open(env_path, 'r') as f:
|
| 35 |
-
content = f.read()
|
| 36 |
-
|
| 37 |
-
if 'FIREBASE_CREDENTIALS_PATH' not in content:
|
| 38 |
-
print("⚠️ FIREBASE_CREDENTIALS_PATH not found in .env")
|
| 39 |
-
print(" Adding it now...")
|
| 40 |
-
|
| 41 |
-
with open(env_path, 'a') as f:
|
| 42 |
-
f.write("\n# Firebase Configuration\n")
|
| 43 |
-
f.write("FIREBASE_CREDENTIALS_PATH=firebase-credentials.json\n")
|
| 44 |
-
|
| 45 |
-
print("✅ Added FIREBASE_CREDENTIALS_PATH to .env")
|
| 46 |
-
else:
|
| 47 |
-
print("✅ .env file configured for Firebase")
|
| 48 |
-
|
| 49 |
-
return True
|
| 50 |
-
|
| 51 |
-
def check_gitignore():
|
| 52 |
-
"""Ensure firebase credentials are in .gitignore"""
|
| 53 |
-
gitignore_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), '.gitignore')
|
| 54 |
-
|
| 55 |
-
if os.path.exists(gitignore_path):
|
| 56 |
-
with open(gitignore_path, 'r') as f:
|
| 57 |
-
content = f.read()
|
| 58 |
-
|
| 59 |
-
if 'firebase-credentials.json' not in content:
|
| 60 |
-
print("⚠️ Adding firebase-credentials.json to .gitignore...")
|
| 61 |
-
with open(gitignore_path, 'a') as f:
|
| 62 |
-
f.write("\n# Firebase credentials\n")
|
| 63 |
-
f.write("firebase-credentials.json\n")
|
| 64 |
-
print("✅ Updated .gitignore")
|
| 65 |
-
else:
|
| 66 |
-
print("✅ .gitignore already includes Firebase credentials")
|
| 67 |
-
else:
|
| 68 |
-
print("⚠️ No .gitignore found - creating one...")
|
| 69 |
-
with open(gitignore_path, 'w') as f:
|
| 70 |
-
f.write("# Firebase credentials\n")
|
| 71 |
-
f.write("firebase-credentials.json\n")
|
| 72 |
-
print("✅ Created .gitignore")
|
| 73 |
-
|
| 74 |
-
def test_firebase_connection():
|
| 75 |
-
"""Test Firebase connection"""
|
| 76 |
-
try:
|
| 77 |
-
from utils.firebase_db import firebase_db_manager
|
| 78 |
-
|
| 79 |
-
print("\n🔄 Testing Firebase connection...")
|
| 80 |
-
success = firebase_db_manager.connect()
|
| 81 |
-
|
| 82 |
-
if success:
|
| 83 |
-
print("✅ Successfully connected to Firebase!")
|
| 84 |
-
return True
|
| 85 |
-
else:
|
| 86 |
-
print("❌ Failed to connect to Firebase")
|
| 87 |
-
return False
|
| 88 |
-
|
| 89 |
-
except ImportError as e:
|
| 90 |
-
print(f"❌ Import error: {e}")
|
| 91 |
-
print(" Make sure firebase-admin is installed: pip install firebase-admin")
|
| 92 |
-
return False
|
| 93 |
-
except Exception as e:
|
| 94 |
-
print(f"❌ Connection error: {e}")
|
| 95 |
-
return False
|
| 96 |
-
|
| 97 |
-
def main():
|
| 98 |
-
"""Run all checks"""
|
| 99 |
-
print("=" * 60)
|
| 100 |
-
print("🔥 Firebase Setup Verification")
|
| 101 |
-
print("=" * 60)
|
| 102 |
-
print()
|
| 103 |
-
|
| 104 |
-
checks = [
|
| 105 |
-
("Firebase Credentials", check_firebase_credentials),
|
| 106 |
-
(".env Configuration", check_env_file),
|
| 107 |
-
(".gitignore Setup", check_gitignore),
|
| 108 |
-
]
|
| 109 |
-
|
| 110 |
-
all_passed = True
|
| 111 |
-
for name, check_func in checks:
|
| 112 |
-
print(f"\n📋 Checking {name}...")
|
| 113 |
-
if not check_func():
|
| 114 |
-
all_passed = False
|
| 115 |
-
|
| 116 |
-
print("\n" + "=" * 60)
|
| 117 |
-
|
| 118 |
-
if all_passed:
|
| 119 |
-
print("✅ All checks passed!")
|
| 120 |
-
print("\n🔄 Testing connection...")
|
| 121 |
-
if test_firebase_connection():
|
| 122 |
-
print("\n🎉 Firebase is ready to use!")
|
| 123 |
-
print("\n📝 Next steps:")
|
| 124 |
-
print(" 1. Update main.py to use Firebase:")
|
| 125 |
-
print(" from utils.firebase_db import firebase_db_manager as db_manager")
|
| 126 |
-
print(" 2. Restart your server")
|
| 127 |
-
print(" 3. Test user registration and login")
|
| 128 |
-
else:
|
| 129 |
-
print("\n⚠️ Setup complete but connection failed")
|
| 130 |
-
print(" Check your Firebase credentials and try again")
|
| 131 |
-
else:
|
| 132 |
-
print("❌ Some checks failed. Please fix the issues above.")
|
| 133 |
-
|
| 134 |
-
print("=" * 60)
|
| 135 |
-
|
| 136 |
-
if __name__ == "__main__":
|
| 137 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/test_flow.py
DELETED
|
@@ -1,120 +0,0 @@
|
|
| 1 |
-
from fastapi.testclient import TestClient
|
| 2 |
-
from unittest.mock import MagicMock, patch
|
| 3 |
-
import sys
|
| 4 |
-
import os
|
| 5 |
-
|
| 6 |
-
# Ensure we can import backend modules
|
| 7 |
-
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
| 8 |
-
|
| 9 |
-
# Patch db_manager BEFORE importing main to ensure it's mocked
|
| 10 |
-
with patch('utils.db.db_manager') as mock_db:
|
| 11 |
-
from main import app
|
| 12 |
-
from utils.errors import VoiceDetectionError
|
| 13 |
-
|
| 14 |
-
client = TestClient(app)
|
| 15 |
-
|
| 16 |
-
def test_full_system_flow():
|
| 17 |
-
print("\n--- Starting System Verification (Mocked DB) ---")
|
| 18 |
-
|
| 19 |
-
# Setup Mock Return Values
|
| 20 |
-
test_email = "test@example.com"
|
| 21 |
-
test_password = "securePassword123!"
|
| 22 |
-
|
| 23 |
-
# Generate valid bcrypt hash
|
| 24 |
-
import bcrypt
|
| 25 |
-
hashed_pw = bcrypt.hashpw(test_password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
|
| 26 |
-
|
| 27 |
-
# Mock User Object effectively
|
| 28 |
-
user_obj = {
|
| 29 |
-
"email": test_email,
|
| 30 |
-
"password_hash": hashed_pw,
|
| 31 |
-
"full_name": "Test User",
|
| 32 |
-
"_id": "dummy_id",
|
| 33 |
-
"api_key": "dummy_api_key_12345" # Added API key
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
# Use side_effect to return different values on consecutive calls
|
| 37 |
-
# 1. Register -> Check if user exists (Should return None)
|
| 38 |
-
# 2. Login -> Get user by email (Should return user_obj)
|
| 39 |
-
# 3. Auth Me / Stats -> Get user by email (Should return user_obj)
|
| 40 |
-
mock_db.get_user_by_email.side_effect = [None, user_obj, user_obj, user_obj]
|
| 41 |
-
|
| 42 |
-
# Mock create_user
|
| 43 |
-
mock_db.create_user.return_value = user_obj
|
| 44 |
-
|
| 45 |
-
# Mock authenticate_user
|
| 46 |
-
mock_db.authenticate_user.return_value = user_obj
|
| 47 |
-
|
| 48 |
-
# Mock get_user_stats
|
| 49 |
-
mock_db.get_user_stats.return_value = {
|
| 50 |
-
"total_tests": 10,
|
| 51 |
-
"ai_detected": 5,
|
| 52 |
-
"human_detected": 5,
|
| 53 |
-
"avg_confidence": 0.85
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
# 1. Register User
|
| 57 |
-
print(f"1. Registering user: {test_email}")
|
| 58 |
-
response = client.post("/auth/register", json={
|
| 59 |
-
"email": test_email,
|
| 60 |
-
"password": test_password,
|
| 61 |
-
"full_name": "Test User"
|
| 62 |
-
})
|
| 63 |
-
|
| 64 |
-
if response.status_code == 201: # Check for 201 Created
|
| 65 |
-
print("✅ Registration Successful")
|
| 66 |
-
else:
|
| 67 |
-
print(f"❌ Registration Failed: {response.text}")
|
| 68 |
-
|
| 69 |
-
# 2. Login
|
| 70 |
-
print("2. Logging in...")
|
| 71 |
-
response = client.post("/auth/login", json={
|
| 72 |
-
"email": test_email,
|
| 73 |
-
"password": test_password
|
| 74 |
-
})
|
| 75 |
-
|
| 76 |
-
token = None
|
| 77 |
-
if response.status_code == 200:
|
| 78 |
-
token = response.json()["access_token"]
|
| 79 |
-
print("✅ Login Successful. Token received.")
|
| 80 |
-
else:
|
| 81 |
-
print(f"❌ Login Failed: {response.text}")
|
| 82 |
-
return
|
| 83 |
-
|
| 84 |
-
# 3. Access Dashboard (Protected)
|
| 85 |
-
print("3. Accessing Dashboard Stats...")
|
| 86 |
-
headers = {"Authorization": f"Bearer {token}"}
|
| 87 |
-
|
| 88 |
-
# We need to ensure get_current_user works. It uses db_manager.get_user_by_email
|
| 89 |
-
response = client.get("/dashboard/stats", headers=headers)
|
| 90 |
-
|
| 91 |
-
if response.status_code == 200:
|
| 92 |
-
print("✅ Dashboard Access Successful")
|
| 93 |
-
print(f" Stats: {response.json()}")
|
| 94 |
-
else:
|
| 95 |
-
print(f"❌ Dashboard Access Failed: {response.text}")
|
| 96 |
-
|
| 97 |
-
# 4. Voice Detection (Validation Test)
|
| 98 |
-
print("4. Testing Voice Detection Endpoint (Validation)...")
|
| 99 |
-
|
| 100 |
-
# Uploading random bytes should trigger VoiceDetectionError in AudioProcessor
|
| 101 |
-
# validation logic we added (minimum duration or invalid format)
|
| 102 |
-
import base64
|
| 103 |
-
dummy_audio = base64.b64encode(os.urandom(100)).decode('utf-8')
|
| 104 |
-
|
| 105 |
-
response = client.post("/detect-voice", json={"audio_base64": dummy_audio}, headers=headers)
|
| 106 |
-
|
| 107 |
-
if response.status_code == 400: # We mapped VoiceDetectionError to 400 or 500 depending on handler
|
| 108 |
-
print(f"✅ Validation Working (Rejected with {response.status_code})")
|
| 109 |
-
print(f" Response: {response.json()}")
|
| 110 |
-
elif response.status_code == 422:
|
| 111 |
-
print(f"❌ Validation Failed (Validation Error): {response.json()}")
|
| 112 |
-
elif response.status_code == 500:
|
| 113 |
-
print(f"⚠️ Server Error (Might be expected if exception handler is 500): {response.json()}")
|
| 114 |
-
else:
|
| 115 |
-
print(f"⚠️ Unexpected Status: {response.status_code}")
|
| 116 |
-
|
| 117 |
-
print("\n--- Verification Complete ---")
|
| 118 |
-
|
| 119 |
-
if __name__ == "__main__":
|
| 120 |
-
test_full_system_flow()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
datasets/numpy_datasets/generate_dataset.py
DELETED
|
@@ -1,167 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Synthetic Dataset Generator for AI Voice Detection
|
| 3 |
-
Generates training data based on audio forensic research
|
| 4 |
-
"""
|
| 5 |
-
|
| 6 |
-
import numpy as np
|
| 7 |
-
import os
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
def generate_ai_voice_features(n_samples: int) -> np.ndarray:
|
| 11 |
-
"""
|
| 12 |
-
Generate synthetic features for AI-generated voices
|
| 13 |
-
|
| 14 |
-
AI voices typically have:
|
| 15 |
-
- Low pitch variance
|
| 16 |
-
- High spectral smoothness (low flatness)
|
| 17 |
-
- Minimal energy variation
|
| 18 |
-
- Consistent MFCC patterns
|
| 19 |
-
|
| 20 |
-
Args:
|
| 21 |
-
n_samples: Number of samples to generate
|
| 22 |
-
|
| 23 |
-
Returns:
|
| 24 |
-
np.ndarray: Feature matrix (n_samples x 22 features)
|
| 25 |
-
"""
|
| 26 |
-
features = []
|
| 27 |
-
|
| 28 |
-
for _ in range(n_samples):
|
| 29 |
-
sample = {
|
| 30 |
-
# MFCC features - more uniform for AI
|
| 31 |
-
'mfcc_mean': np.random.uniform(-50, -20),
|
| 32 |
-
'mfcc_std': np.random.uniform(5, 15),
|
| 33 |
-
'mfcc_var': np.random.uniform(25, 100),
|
| 34 |
-
'mfcc_max': np.random.uniform(20, 50),
|
| 35 |
-
'mfcc_min': np.random.uniform(-100, -60),
|
| 36 |
-
|
| 37 |
-
# Pitch features - low variance for AI
|
| 38 |
-
'pitch_mean': np.random.uniform(100, 250),
|
| 39 |
-
'pitch_std': np.random.uniform(5, 25),
|
| 40 |
-
'pitch_variance': np.random.uniform(25, 400),
|
| 41 |
-
'pitch_range': np.random.uniform(20, 100),
|
| 42 |
-
|
| 43 |
-
# Spectral features - smooth for AI
|
| 44 |
-
'spectral_flatness_mean': np.random.uniform(0.01, 0.08),
|
| 45 |
-
'spectral_flatness_std': np.random.uniform(0.01, 0.05),
|
| 46 |
-
'spectral_centroid_mean': np.random.uniform(1000, 3000),
|
| 47 |
-
'spectral_centroid_std': np.random.uniform(100, 400),
|
| 48 |
-
'spectral_rolloff_mean': np.random.uniform(2000, 5000),
|
| 49 |
-
'spectral_bandwidth_mean': np.random.uniform(800, 1500),
|
| 50 |
-
|
| 51 |
-
# Energy features - consistent for AI
|
| 52 |
-
'rms_mean': np.random.uniform(0.05, 0.15),
|
| 53 |
-
'rms_std': np.random.uniform(0.01, 0.04),
|
| 54 |
-
'rms_variance': np.random.uniform(0.0001, 0.002),
|
| 55 |
-
'zcr_mean': np.random.uniform(0.05, 0.15),
|
| 56 |
-
'zcr_std': np.random.uniform(0.005, 0.02),
|
| 57 |
-
|
| 58 |
-
# Temporal features - low variation for AI
|
| 59 |
-
'energy_variation': np.random.uniform(0.1, 0.4),
|
| 60 |
-
'audio_duration': np.random.uniform(1.0, 10.0)
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
features.append(list(sample.values()))
|
| 64 |
-
|
| 65 |
-
return np.array(features)
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
def generate_human_voice_features(n_samples: int) -> np.ndarray:
|
| 69 |
-
"""
|
| 70 |
-
Generate synthetic features for human voices
|
| 71 |
-
|
| 72 |
-
Human voices typically have:
|
| 73 |
-
- High pitch variance
|
| 74 |
-
- Natural spectral roughness
|
| 75 |
-
- Variable energy patterns
|
| 76 |
-
- Diverse MFCC patterns
|
| 77 |
-
|
| 78 |
-
Args:
|
| 79 |
-
n_samples: Number of samples to generate
|
| 80 |
-
|
| 81 |
-
Returns:
|
| 82 |
-
np.ndarray: Feature matrix (n_samples x 22 features)
|
| 83 |
-
"""
|
| 84 |
-
features = []
|
| 85 |
-
|
| 86 |
-
for _ in range(n_samples):
|
| 87 |
-
sample = {
|
| 88 |
-
# MFCC features - more varied for humans
|
| 89 |
-
'mfcc_mean': np.random.uniform(-60, -10),
|
| 90 |
-
'mfcc_std': np.random.uniform(15, 35),
|
| 91 |
-
'mfcc_var': np.random.uniform(100, 300),
|
| 92 |
-
'mfcc_max': np.random.uniform(30, 80),
|
| 93 |
-
'mfcc_min': np.random.uniform(-120, -50),
|
| 94 |
-
|
| 95 |
-
# Pitch features - high variance for humans
|
| 96 |
-
'pitch_mean': np.random.uniform(80, 300),
|
| 97 |
-
'pitch_std': np.random.uniform(25, 60),
|
| 98 |
-
'pitch_variance': np.random.uniform(500, 3000),
|
| 99 |
-
'pitch_range': np.random.uniform(100, 400),
|
| 100 |
-
|
| 101 |
-
# Spectral features - more natural roughness
|
| 102 |
-
'spectral_flatness_mean': np.random.uniform(0.1, 0.4),
|
| 103 |
-
'spectral_flatness_std': np.random.uniform(0.05, 0.15),
|
| 104 |
-
'spectral_centroid_mean': np.random.uniform(1500, 4000),
|
| 105 |
-
'spectral_centroid_std': np.random.uniform(300, 800),
|
| 106 |
-
'spectral_rolloff_mean': np.random.uniform(3000, 7000),
|
| 107 |
-
'spectral_bandwidth_mean': np.random.uniform(1200, 2500),
|
| 108 |
-
|
| 109 |
-
# Energy features - more variation for humans
|
| 110 |
-
'rms_mean': np.random.uniform(0.08, 0.20),
|
| 111 |
-
'rms_std': np.random.uniform(0.04, 0.10),
|
| 112 |
-
'rms_variance': np.random.uniform(0.002, 0.01),
|
| 113 |
-
'zcr_mean': np.random.uniform(0.08, 0.20),
|
| 114 |
-
'zcr_std': np.random.uniform(0.02, 0.06),
|
| 115 |
-
|
| 116 |
-
# Temporal features - higher variation for humans
|
| 117 |
-
'energy_variation': np.random.uniform(0.5, 2.0),
|
| 118 |
-
'audio_duration': np.random.uniform(1.0, 10.0)
|
| 119 |
-
}
|
| 120 |
-
|
| 121 |
-
features.append(list(sample.values()))
|
| 122 |
-
|
| 123 |
-
return np.array(features)
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
def generate_dataset(n_ai_samples: int = 1000, n_human_samples: int = 1000):
|
| 127 |
-
"""
|
| 128 |
-
Generate complete training dataset
|
| 129 |
-
|
| 130 |
-
Args:
|
| 131 |
-
n_ai_samples: Number of AI voice samples
|
| 132 |
-
n_human_samples: Number of human voice samples
|
| 133 |
-
"""
|
| 134 |
-
print("Generating synthetic dataset...")
|
| 135 |
-
|
| 136 |
-
# Generate features
|
| 137 |
-
ai_features = generate_ai_voice_features(n_ai_samples)
|
| 138 |
-
human_features = generate_human_voice_features(n_human_samples)
|
| 139 |
-
|
| 140 |
-
# Create labels (0 = AI, 1 = Human)
|
| 141 |
-
ai_labels = np.zeros(n_ai_samples)
|
| 142 |
-
human_labels = np.ones(n_human_samples)
|
| 143 |
-
|
| 144 |
-
# Combine
|
| 145 |
-
X = np.vstack([ai_features, human_features])
|
| 146 |
-
y = np.hstack([ai_labels, human_labels])
|
| 147 |
-
|
| 148 |
-
# Shuffle
|
| 149 |
-
indices = np.random.permutation(len(X))
|
| 150 |
-
X = X[indices]
|
| 151 |
-
y = y[indices]
|
| 152 |
-
|
| 153 |
-
# Save dataset
|
| 154 |
-
output_dir = os.path.dirname(os.path.abspath(__file__))
|
| 155 |
-
np.save(os.path.join(output_dir, 'X_train.npy'), X)
|
| 156 |
-
np.save(os.path.join(output_dir, 'y_train.npy'), y)
|
| 157 |
-
|
| 158 |
-
print(f"Dataset generated successfully!")
|
| 159 |
-
print(f"Total samples: {len(X)}")
|
| 160 |
-
print(f"AI samples: {n_ai_samples}")
|
| 161 |
-
print(f"Human samples: {n_human_samples}")
|
| 162 |
-
print(f"Features per sample: {X.shape[1]}")
|
| 163 |
-
print(f"Saved to: {output_dir}")
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
if __name__ == "__main__":
|
| 167 |
-
generate_dataset(n_ai_samples=1000, n_human_samples=1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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flex items-center justify-center mb-4">
|
| 49 |
-
<svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 50 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 51 |
-
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2">
|
| 52 |
-
</path>
|
| 53 |
-
</svg>
|
| 54 |
-
</div>
|
| 55 |
-
<h3 class="font-semibold text-gray-900 mb-2">Explainable AI</h3>
|
| 56 |
-
<p class="text-gray-600 text-sm">Understand why a voice is classified with detailed explanations</p>
|
| 57 |
-
</div>
|
| 58 |
-
|
| 59 |
-
<!-- Feature 3 -->
|
| 60 |
-
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200 hover:shadow-md transition-shadow">
|
| 61 |
-
<div class="bg-purple-100 w-12 h-12 rounded-lg flex items-center justify-center mb-4">
|
| 62 |
-
<svg class="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 63 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 64 |
-
d="M3 5h12M9 3v2m1.048 9.5A18.022 18.022 0 016.412 9m6.088 9h7M11 21l5-10 5 10M12.751 5C11.783 10.77 8.07 15.61 3 18.129">
|
| 65 |
-
</path>
|
| 66 |
-
</svg>
|
| 67 |
-
</div>
|
| 68 |
-
<h3 class="font-semibold text-gray-900 mb-2">Multi-Language</h3>
|
| 69 |
-
<p class="text-gray-600 text-sm">Supports Tamil, English, Hindi, Malayalam, and Telugu</p>
|
| 70 |
-
</div>
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
</main>
|
| 92 |
|
| 93 |
<!-- Team Footer -->
|
|
|
|
| 29 |
</div>
|
| 30 |
</nav>
|
| 31 |
|
| 32 |
+
<!-- Hero Section Content -->
|
| 33 |
+
<main class="container mx-auto px-6 py-12">
|
| 34 |
+
<div class="max-w-4xl mx-auto text-center">
|
| 35 |
+
<h1 class="text-5xl md:text-6xl font-extrabold text-gray-900 mb-6 tracking-tight"
|
| 36 |
+
style="color: var(--text-color);">
|
| 37 |
+
Verify Every <span class="gradient-text">Voice</span>
|
| 38 |
+
</h1>
|
| 39 |
+
<p class="text-lg text-gray-600 mb-10 max-w-2xl mx-auto" style="color: var(--text-muted);">
|
| 40 |
+
Protect yourself from deepfakes and AI voice clones. Our advanced forensic analysis detects
|
| 41 |
+
AI-generated audio with industry-leading precision.
|
| 42 |
+
</p>
|
| 43 |
|
| 44 |
+
<div class="grid md:grid-cols-3 gap-8 mb-16">
|
| 45 |
+
<!-- Feature 1 -->
|
| 46 |
+
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200 hover:shadow-md transition-shadow"
|
| 47 |
+
style="background: var(--card-bg); border-color: var(--card-border);">
|
| 48 |
+
<div class="bg-green-100 w-12 h-12 rounded-lg flex items-center justify-center mb-4">
|
| 49 |
+
<svg class="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 50 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 51 |
+
d="M13 10V3L4 14h7v7l9-11h-7z"></path>
|
| 52 |
+
</svg>
|
| 53 |
+
</div>
|
| 54 |
+
<h3 class="font-semibold text-gray-900 mb-2" style="color: var(--text-color);">Fast & Accurate</h3>
|
| 55 |
+
<p class="text-gray-600 text-sm" style="color: var(--text-muted);">Get results in seconds with high
|
| 56 |
+
accuracy using trained ML models</p>
|
| 57 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
<!-- Feature 2 -->
|
| 60 |
+
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200 hover:shadow-md transition-shadow"
|
| 61 |
+
style="background: var(--card-bg); border-color: var(--card-border);">
|
| 62 |
+
<div class="bg-blue-100 w-12 h-12 rounded-lg flex items-center justify-center mb-4">
|
| 63 |
+
<svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 64 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 65 |
+
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2">
|
| 66 |
+
</path>
|
| 67 |
+
</svg>
|
| 68 |
+
</div>
|
| 69 |
+
<h3 class="font-semibold text-gray-900 mb-2" style="color: var(--text-color);">Explainable AI</h3>
|
| 70 |
+
<p class="text-gray-600 text-sm" style="color: var(--text-muted);">Understand why a voice is
|
| 71 |
+
classified with detailed explanations</p>
|
| 72 |
+
</div>
|
| 73 |
|
| 74 |
+
<!-- Feature 3 -->
|
| 75 |
+
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200 hover:shadow-md transition-shadow"
|
| 76 |
+
style="background: var(--card-bg); border-color: var(--card-border);">
|
| 77 |
+
<div class="bg-purple-100 w-12 h-12 rounded-lg flex items-center justify-center mb-4">
|
| 78 |
+
<svg class="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 79 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 80 |
+
d="M3 5h12M9 3v2m1.048 9.5A18.022 18.022 0 016.412 9m6.088 9h7M11 21l5-10 5 10M12.751 5C11.783 10.77 8.07 15.61 3 18.129">
|
| 81 |
+
</path>
|
| 82 |
+
</svg>
|
| 83 |
+
</div>
|
| 84 |
+
<h3 class="font-semibold text-gray-900 mb-2" style="color: var(--text-color);">Multi-Language</h3>
|
| 85 |
+
<p class="text-gray-600 text-sm" style="color: var(--text-muted);">Supports Tamil, English, Hindi,
|
| 86 |
+
Malayalam, and Telugu</p>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
|
| 90 |
+
<!-- CTA Button -->
|
| 91 |
+
<div class="mb-8">
|
| 92 |
+
<a href="upload.html"
|
| 93 |
+
class="inline-block bg-blue-600 hover:bg-blue-700 text-white font-semibold px-8 py-4 rounded-lg shadow-lg hover:shadow-xl transition-all transform hover:scale-105">
|
| 94 |
+
Upload Audio File
|
| 95 |
+
<svg class="inline-block w-5 h-5 ml-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 96 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
|
| 97 |
+
</svg>
|
| 98 |
+
</a>
|
| 99 |
+
</div>
|
| 100 |
|
| 101 |
+
<!-- Supported Formats -->
|
| 102 |
+
<div class="text-sm text-gray-500" style="color: var(--text-muted);">
|
| 103 |
+
<p>Supported format: MP3 • Maximum file size: 10MB</p>
|
| 104 |
+
</div>
|
| 105 |
+
</div>
|
| 106 |
</main>
|
| 107 |
|
| 108 |
<!-- Team Footer -->
|
frontend/register.html
CHANGED
|
@@ -60,40 +60,6 @@
|
|
| 60 |
border-color: #4a90e2;
|
| 61 |
}
|
| 62 |
|
| 63 |
-
.password-strength {
|
| 64 |
-
margin-top: 8px;
|
| 65 |
-
font-size: 12px;
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
.strength-bar {
|
| 69 |
-
height: 4px;
|
| 70 |
-
background: #e0e0e0;
|
| 71 |
-
border-radius: 2px;
|
| 72 |
-
margin-top: 4px;
|
| 73 |
-
overflow: hidden;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
.strength-fill {
|
| 77 |
-
height: 100%;
|
| 78 |
-
transition: width 0.3s, background-color 0.3s;
|
| 79 |
-
width: 0%;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
.strength-weak {
|
| 83 |
-
background: #f44336;
|
| 84 |
-
width: 33%;
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
.strength-medium {
|
| 88 |
-
background: #ff9800;
|
| 89 |
-
width: 66%;
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
.strength-strong {
|
| 93 |
-
background: #4caf50;
|
| 94 |
-
width: 100%;
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
.btn-primary {
|
| 98 |
width: 100%;
|
| 99 |
padding: 14px;
|
|
@@ -184,73 +150,124 @@
|
|
| 184 |
</div>
|
| 185 |
<div class="auth-container">
|
| 186 |
<div class="auth-header">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
try {
|
| 188 |
-
|
| 189 |
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
|
| 198 |
-
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
|
| 218 |
} catch (error) {
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
}
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
</div>
|
| 250 |
-
</div>
|
| 251 |
-
<p class="footer-note">Responsive UI • Optimized for all screen sizes</p>
|
| 252 |
</div>
|
| 253 |
-
</
|
|
|
|
|
|
|
|
|
|
| 254 |
</body>
|
| 255 |
|
| 256 |
</html>
|
|
|
|
| 60 |
border-color: #4a90e2;
|
| 61 |
}
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
.btn-primary {
|
| 64 |
width: 100%;
|
| 65 |
padding: 14px;
|
|
|
|
| 150 |
</div>
|
| 151 |
<div class="auth-container">
|
| 152 |
<div class="auth-header">
|
| 153 |
+
<h1>🎤 Create Account</h1>
|
| 154 |
+
<p>Join us to detect AI-generated voices</p>
|
| 155 |
+
</div>
|
| 156 |
+
|
| 157 |
+
<div id="errorMessage" class="error-message"></div>
|
| 158 |
+
<div id="successMessage" class="success-message"></div>
|
| 159 |
+
|
| 160 |
+
<form id="registerForm">
|
| 161 |
+
<div class="form-group">
|
| 162 |
+
<label for="email">Email Address</label>
|
| 163 |
+
<input type="email" id="email" name="email" placeholder="your@email.com" required autocomplete="email">
|
| 164 |
+
</div>
|
| 165 |
+
|
| 166 |
+
<div class="form-group">
|
| 167 |
+
<label for="password">Password</label>
|
| 168 |
+
<input type="password" id="password" name="password" placeholder="Min 8 characters" required
|
| 169 |
+
autocomplete="new-password" minlength="8">
|
| 170 |
+
</div>
|
| 171 |
+
|
| 172 |
+
<button type="submit" class="btn-primary" id="registerBtn">
|
| 173 |
+
Create Account
|
| 174 |
+
</button>
|
| 175 |
+
</form>
|
| 176 |
+
|
| 177 |
+
<div class="auth-footer">
|
| 178 |
+
Already have an account? <a href="login.html">Login</a>
|
| 179 |
+
</div>
|
| 180 |
+
</div>
|
| 181 |
+
|
| 182 |
+
<script>
|
| 183 |
+
const API_URL = '';
|
| 184 |
+
|
| 185 |
+
const registerForm = document.getElementById('registerForm');
|
| 186 |
+
const registerBtn = document.getElementById('registerBtn');
|
| 187 |
+
const errorMessage = document.getElementById('errorMessage');
|
| 188 |
+
const successMessage = document.getElementById('successMessage');
|
| 189 |
+
|
| 190 |
+
registerForm.addEventListener('submit', async (e) => {
|
| 191 |
+
e.preventDefault();
|
| 192 |
+
|
| 193 |
+
const email = document.getElementById('email').value;
|
| 194 |
+
const password = document.getElementById('password').value;
|
| 195 |
+
|
| 196 |
+
// Hide previous messages
|
| 197 |
+
errorMessage.style.display = 'none';
|
| 198 |
+
successMessage.style.display = 'none';
|
| 199 |
+
|
| 200 |
+
// Disable button and show loading
|
| 201 |
+
registerBtn.disabled = true;
|
| 202 |
+
registerBtn.innerHTML = '<span class="loading-spinner"></span>Creating account...';
|
| 203 |
+
|
| 204 |
try {
|
| 205 |
+
const url = `${API_URL}auth/register`;
|
| 206 |
|
| 207 |
+
const response = await fetch(url, {
|
| 208 |
+
method: 'POST',
|
| 209 |
+
headers: {
|
| 210 |
+
'Content-Type': 'application/json'
|
| 211 |
+
},
|
| 212 |
+
body: JSON.stringify({ email, password })
|
| 213 |
+
});
|
| 214 |
|
| 215 |
+
const data = await response.json();
|
| 216 |
|
| 217 |
+
if (!response.ok) {
|
| 218 |
+
throw new Error(data.message || data.detail?.message || 'Registration failed');
|
| 219 |
+
}
|
| 220 |
|
| 221 |
+
// Store token and user info
|
| 222 |
+
localStorage.setItem('access_token', data.access_token);
|
| 223 |
+
localStorage.setItem('user_email', data.user_email);
|
| 224 |
+
localStorage.setItem('api_key', data.api_key);
|
| 225 |
|
| 226 |
+
// Show success message
|
| 227 |
+
successMessage.textContent = 'Account created successfully! Redirecting...';
|
| 228 |
+
successMessage.style.display = 'block';
|
| 229 |
|
| 230 |
+
// Redirect to dashboard
|
| 231 |
+
setTimeout(() => {
|
| 232 |
+
window.location.href = 'dashboard.html';
|
| 233 |
+
}, 1500);
|
| 234 |
|
| 235 |
} catch (error) {
|
| 236 |
+
console.error('Registration error:', error);
|
| 237 |
+
errorMessage.textContent = error.message;
|
| 238 |
+
errorMessage.style.display = 'block';
|
| 239 |
|
| 240 |
+
// Re-enable button
|
| 241 |
+
registerBtn.disabled = false;
|
| 242 |
+
registerBtn.innerHTML = 'Create Account';
|
| 243 |
}
|
| 244 |
+
});
|
| 245 |
+
</script>
|
| 246 |
+
<!-- Team Footer -->
|
| 247 |
+
<footer class="team-footer">
|
| 248 |
+
<div class="footer-divider"></div>
|
| 249 |
+
<div class="footer-content">
|
| 250 |
+
<h2 class="team-name">Bug Hunterx</h2>
|
| 251 |
+
<h3>Built by</h3>
|
| 252 |
+
<div class="team-members">
|
| 253 |
+
<div class="member">
|
| 254 |
+
<span class="name">Mohammed Meraj Uddin</span>
|
| 255 |
+
<a href="https://www.linkedin.com/in/merajuddin-0751a6396" target="_blank"
|
| 256 |
+
aria-label="LinkedIn for Mohammed Meraj Uddin">
|
| 257 |
+
<i class="fab fa-linkedin"></i>
|
| 258 |
+
</a>
|
| 259 |
+
</div>
|
| 260 |
+
<div class="member">
|
| 261 |
+
<span class="name">Mohd Basheer Ahmed</span>
|
| 262 |
+
<a href="https://www.linkedin.com/in/mohd-basheer-ahmed-5247593a6" target="_blank"
|
| 263 |
+
aria-label="LinkedIn for Mohd Basheer Ahmed">
|
| 264 |
+
<i class="fab fa-linkedin"></i>
|
| 265 |
+
</a>
|
|
|
|
|
|
|
|
|
|
| 266 |
</div>
|
| 267 |
+
</div>
|
| 268 |
+
<p class="footer-note">Responsive UI • Optimized for all screen sizes</p>
|
| 269 |
+
</div>
|
| 270 |
+
</footer>
|
| 271 |
</body>
|
| 272 |
|
| 273 |
</html>
|
render.yaml
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
services:
|
| 2 |
-
# Backend Web Service
|
| 3 |
-
- type: web
|
| 4 |
-
name: ai-voice-detector-api
|
| 5 |
-
env: python
|
| 6 |
-
buildCommand: pip install -r backend/requirements.txt
|
| 7 |
-
startCommand: cd backend && python main.py
|
| 8 |
-
envVars:
|
| 9 |
-
- key: MONGODB_URI
|
| 10 |
-
sync: false
|
| 11 |
-
- key: JWT_SECRET_KEY
|
| 12 |
-
generateValue: true
|
| 13 |
-
- key: API_KEY
|
| 14 |
-
sync: false
|
| 15 |
-
|
| 16 |
-
# Frontend Static Site
|
| 17 |
-
- type: web
|
| 18 |
-
name: ai-voice-detector-ui
|
| 19 |
-
runtime: static
|
| 20 |
-
buildCommand: "" # No build step needed for vanilla HTML/JS
|
| 21 |
-
staticPublishPath: frontend
|
| 22 |
-
envVars:
|
| 23 |
-
- key: API_BASE_URL
|
| 24 |
-
value: https://ai-voice-detector-api.onrender.com # Use your backend service name here
|
|
|
|
|
|
|
|
|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d3cuZ29vZ2xlYXBpcy5jb20vcm9ib3QvdjEvbWV0YWRhdGEveDUwOS9maXJlYmFzZS1hZG1pbnNkay1mYnN2YyU0MHZvaWNlZGV0ZWN0b3ItMzk0ZTEuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iLAogICJ1bml2ZXJzZV9kb21haW4iOiAiZ29vZ2xlYXBpcy5jb20iCn0K
|
|
|
|
|
|
setup.sh
DELETED
|
@@ -1,97 +0,0 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
|
| 3 |
-
# AI Voice Detection System - Setup Script
|
| 4 |
-
# This script sets up the complete environment
|
| 5 |
-
|
| 6 |
-
set -e
|
| 7 |
-
|
| 8 |
-
echo "=========================================="
|
| 9 |
-
echo "AI Voice Detection System - Setup"
|
| 10 |
-
echo "=========================================="
|
| 11 |
-
echo ""
|
| 12 |
-
|
| 13 |
-
# Check Python version
|
| 14 |
-
echo "Checking Python installation..."
|
| 15 |
-
if ! command -v python3 &> /dev/null; then
|
| 16 |
-
echo "❌ Python 3 is not installed. Please install Python 3.8 or higher."
|
| 17 |
-
exit 1
|
| 18 |
-
fi
|
| 19 |
-
|
| 20 |
-
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2)
|
| 21 |
-
echo "✓ Found Python $PYTHON_VERSION"
|
| 22 |
-
echo ""
|
| 23 |
-
|
| 24 |
-
# Check FFmpeg
|
| 25 |
-
echo "Checking FFmpeg installation..."
|
| 26 |
-
if ! command -v ffmpeg &> /dev/null; then
|
| 27 |
-
echo "⚠️ FFmpeg is not installed."
|
| 28 |
-
echo " Please install FFmpeg:"
|
| 29 |
-
echo " - macOS: brew install ffmpeg"
|
| 30 |
-
echo " - Ubuntu: sudo apt-get install ffmpeg"
|
| 31 |
-
echo ""
|
| 32 |
-
read -p "Continue without FFmpeg? (y/n) " -n 1 -r
|
| 33 |
-
echo
|
| 34 |
-
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
| 35 |
-
exit 1
|
| 36 |
-
fi
|
| 37 |
-
else
|
| 38 |
-
echo "✓ FFmpeg is installed"
|
| 39 |
-
fi
|
| 40 |
-
echo ""
|
| 41 |
-
|
| 42 |
-
# Create virtual environment
|
| 43 |
-
echo "Creating virtual environment..."
|
| 44 |
-
cd backend
|
| 45 |
-
python3 -m venv venv
|
| 46 |
-
echo "✓ Virtual environment created"
|
| 47 |
-
echo ""
|
| 48 |
-
|
| 49 |
-
# Activate virtual environment
|
| 50 |
-
echo "Activating virtual environment..."
|
| 51 |
-
source venv/bin/activate
|
| 52 |
-
echo "✓ Virtual environment activated"
|
| 53 |
-
echo ""
|
| 54 |
-
|
| 55 |
-
# Install dependencies
|
| 56 |
-
echo "Installing Python dependencies..."
|
| 57 |
-
pip install --upgrade pip
|
| 58 |
-
pip install -r requirements.txt
|
| 59 |
-
echo "✓ Dependencies installed"
|
| 60 |
-
echo ""
|
| 61 |
-
|
| 62 |
-
# Create .env file
|
| 63 |
-
echo "Setting up environment variables..."
|
| 64 |
-
if [ ! -f .env ]; then
|
| 65 |
-
cp .env.example .env
|
| 66 |
-
echo "✓ Created .env file"
|
| 67 |
-
echo "⚠️ Please edit backend/.env and set your API_KEY and MONGODB_URI"
|
| 68 |
-
else
|
| 69 |
-
echo "✓ .env file already exists"
|
| 70 |
-
fi
|
| 71 |
-
echo ""
|
| 72 |
-
|
| 73 |
-
# Generate dataset
|
| 74 |
-
echo "Generating training dataset..."
|
| 75 |
-
cd ../datasets/numpy_datasets
|
| 76 |
-
python3 generate_dataset.py
|
| 77 |
-
echo "✓ Dataset generated"
|
| 78 |
-
echo ""
|
| 79 |
-
|
| 80 |
-
# Train model
|
| 81 |
-
echo "Training ML model..."
|
| 82 |
-
cd ../../backend
|
| 83 |
-
python3 model/train_model.py
|
| 84 |
-
echo "✓ Model trained successfully"
|
| 85 |
-
echo ""
|
| 86 |
-
|
| 87 |
-
echo "=========================================="
|
| 88 |
-
echo "✅ Setup Complete!"
|
| 89 |
-
echo "=========================================="
|
| 90 |
-
echo ""
|
| 91 |
-
echo "Next steps:"
|
| 92 |
-
echo "1. Edit backend/.env and set your API_KEY and MONGODB_URI"
|
| 93 |
-
echo "2. Start MongoDB (if using local instance)"
|
| 94 |
-
echo "3. Run: cd backend && source venv/bin/activate && uvicorn main:app --reload"
|
| 95 |
-
echo "4. Open frontend/index.html in your browser"
|
| 96 |
-
echo ""
|
| 97 |
-
echo "Happy hacking! 🚀"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
upload_to_hf.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from huggingface_hub import HfApi
|
| 3 |
-
|
| 4 |
-
# --- CONFIGURATION ---
|
| 5 |
-
REPO_ID = "BugHu/voice-detector" # Your username/space-name
|
| 6 |
-
TOKEN = os.getenv("HF_TOKEN") # Get token from environment
|
| 7 |
-
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
| 8 |
-
|
| 9 |
-
def upload_to_hf():
|
| 10 |
-
api = HfApi()
|
| 11 |
-
|
| 12 |
-
print(f"🚀 Starting automated upload to {REPO_ID}...")
|
| 13 |
-
|
| 14 |
-
# 1. Upload the Dockerfile
|
| 15 |
-
api.upload_file(
|
| 16 |
-
path_or_fileobj=os.path.join(PROJECT_ROOT, "Dockerfile"),
|
| 17 |
-
path_in_repo="Dockerfile",
|
| 18 |
-
repo_id=REPO_ID,
|
| 19 |
-
repo_type="space",
|
| 20 |
-
token=TOKEN
|
| 21 |
-
)
|
| 22 |
-
print("✅ Uploaded Dockerfile")
|
| 23 |
-
|
| 24 |
-
# 2. Upload the README.md (contains Space metadata)
|
| 25 |
-
api.upload_file(
|
| 26 |
-
path_or_fileobj=os.path.join(PROJECT_ROOT, "README.md"),
|
| 27 |
-
path_in_repo="README.md",
|
| 28 |
-
repo_id=REPO_ID,
|
| 29 |
-
repo_type="space",
|
| 30 |
-
token=TOKEN
|
| 31 |
-
)
|
| 32 |
-
print("✅ Uploaded README.md")
|
| 33 |
-
|
| 34 |
-
# 3. Upload the backend folder
|
| 35 |
-
api.upload_folder(
|
| 36 |
-
folder_path=os.path.join(PROJECT_ROOT, "backend"),
|
| 37 |
-
path_in_repo="backend",
|
| 38 |
-
repo_id=REPO_ID,
|
| 39 |
-
repo_type="space",
|
| 40 |
-
token=TOKEN,
|
| 41 |
-
ignore_patterns=["*.env", "__pycache__", "*.pyc", ".venv"]
|
| 42 |
-
)
|
| 43 |
-
print("✅ Uploaded backend/ folder")
|
| 44 |
-
|
| 45 |
-
# 4. Upload the frontend folder
|
| 46 |
-
api.upload_folder(
|
| 47 |
-
folder_path=os.path.join(PROJECT_ROOT, "frontend"),
|
| 48 |
-
path_in_repo="frontend",
|
| 49 |
-
repo_id=REPO_ID,
|
| 50 |
-
repo_type="space",
|
| 51 |
-
token=TOKEN
|
| 52 |
-
)
|
| 53 |
-
print("✅ Uploaded frontend/ folder")
|
| 54 |
-
|
| 55 |
-
print(f"\n✨ DONE! Your app is now building at: https://huggingface.co/spaces/{REPO_ID}")
|
| 56 |
-
print("Wait 2-3 minutes for the build to finish. Don't forget to add your MONGODB_URI in Space Settings!")
|
| 57 |
-
|
| 58 |
-
if __name__ == "__main__":
|
| 59 |
-
upload_to_hf()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|