Spaces:
Sleeping
Sleeping
Upload 6 files
Browse files- Dockerfile +23 -0
- Procfile +0 -0
- README.md +69 -5
- app.py +9 -0
- requirements.txt +12 -0
- runtime.txt +1 -0
Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
+
|
| 3 |
+
# Install system dependencies for audio processing
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
ffmpeg \
|
| 6 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 7 |
+
|
| 8 |
+
# Set working directory
|
| 9 |
+
WORKDIR /app
|
| 10 |
+
|
| 11 |
+
# Copy requirements and install Python dependencies
|
| 12 |
+
COPY requirements.txt .
|
| 13 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
+
|
| 15 |
+
# Copy application code
|
| 16 |
+
COPY . .
|
| 17 |
+
|
| 18 |
+
# Expose port (Hugging Face Spaces uses port 7860)
|
| 19 |
+
EXPOSE 7860
|
| 20 |
+
|
| 21 |
+
# Run the FastAPI app
|
| 22 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 23 |
+
|
Procfile
ADDED
|
Binary file (176 Bytes). View file
|
|
|
README.md
CHANGED
|
@@ -1,10 +1,74 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
|
|
|
| 7 |
pinned: false
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: AI Voice Detection API
|
| 3 |
+
emoji: 🎤
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: docker
|
| 7 |
+
sdk_version: 4.38.0
|
| 8 |
+
app_port: 7860
|
| 9 |
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# AI Voice Detection API
|
| 14 |
+
|
| 15 |
+
Detects whether a voice sample is AI-generated or human across multiple languages.
|
| 16 |
+
|
| 17 |
+
## Supported Languages
|
| 18 |
+
- Tamil
|
| 19 |
+
- English
|
| 20 |
+
- Hindi
|
| 21 |
+
- Malayalam
|
| 22 |
+
- Telugu
|
| 23 |
+
|
| 24 |
+
## Features
|
| 25 |
+
- FastAPI-based REST API
|
| 26 |
+
- Wav2Vec2 embeddings + signal feature extraction
|
| 27 |
+
- Pre-trained classifier for AI/Human voice detection
|
| 28 |
+
- Base64 MP3 audio input
|
| 29 |
+
- API key protected endpoints
|
| 30 |
+
|
| 31 |
+
## API Endpoints
|
| 32 |
+
|
| 33 |
+
### Health Check
|
| 34 |
+
```
|
| 35 |
+
GET /health
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
### Voice Detection
|
| 39 |
+
```
|
| 40 |
+
POST /api/voice-detection
|
| 41 |
+
Headers:
|
| 42 |
+
x-api-key: <your-api-key>
|
| 43 |
+
|
| 44 |
+
Body:
|
| 45 |
+
{
|
| 46 |
+
"language": "English",
|
| 47 |
+
"audioFormat": "mp3",
|
| 48 |
+
"audioBase64": "<base64-encoded-audio>"
|
| 49 |
+
}
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## Response Format
|
| 53 |
+
```json
|
| 54 |
+
{
|
| 55 |
+
"status": "success",
|
| 56 |
+
"language": "English",
|
| 57 |
+
"classification": "HUMAN" | "AI_GENERATED",
|
| 58 |
+
"confidenceScore": 0.95,
|
| 59 |
+
"explanation": "Natural prosody, breathing patterns..."
|
| 60 |
+
}
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## Environment Variables
|
| 64 |
+
- `API_KEY`: API key for authentication (default: "hackathon-secret")
|
| 65 |
+
|
| 66 |
+
## Model Architecture
|
| 67 |
+
- Uses Facebook's Wav2Vec2-base for audio embeddings
|
| 68 |
+
- Extracts signal features (pitch variance, spectral centroid, zero-crossing rate)
|
| 69 |
+
- Logistic regression classifier for final prediction
|
| 70 |
+
|
| 71 |
+
## Team
|
| 72 |
+
- ML: Gunashree
|
| 73 |
+
- Backend: Tanu
|
| 74 |
+
- DevOps/QA: Pavithra
|
app.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Hugging Face Spaces entry point for AI Voice Detection API
|
| 3 |
+
This file imports the FastAPI app from app/main.py
|
| 4 |
+
"""
|
| 5 |
+
from app.main import app
|
| 6 |
+
|
| 7 |
+
# Hugging Face Spaces will automatically detect and serve this app
|
| 8 |
+
__all__ = ["app"]
|
| 9 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn[standard]
|
| 3 |
+
pydantic
|
| 4 |
+
pydub
|
| 5 |
+
librosa
|
| 6 |
+
numpy
|
| 7 |
+
torch
|
| 8 |
+
transformers
|
| 9 |
+
scikit-learn
|
| 10 |
+
joblib
|
| 11 |
+
soundfile
|
| 12 |
+
ffmpeg-python
|
runtime.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
python-3.9.13
|