Spaces:
Sleeping
Sleeping
ranar110 commited on
Commit Β·
88d3035
1
Parent(s): 728c5f3
Final: Add submission details and cheatsheets
Browse files- check_ai_deployment.py +46 -0
- quick_check.py +19 -0
- submission.md +58 -0
- submission_cheatsheet.md +42 -0
check_ai_deployment.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
print("Waiting for Hugging Face Space to rebuild with REAL AI MODEL...")
|
| 5 |
+
print("This may take 5-10 minutes due to PyTorch installation.")
|
| 6 |
+
print("=" * 70)
|
| 7 |
+
|
| 8 |
+
base_url = "https://ranar118-voice-detection.hf.space"
|
| 9 |
+
|
| 10 |
+
# Increased timeout and attempts for heavier build
|
| 11 |
+
for attempt in range(1, 30):
|
| 12 |
+
print(f"\nAttempt {attempt}/30 (checking every 30 seconds)...")
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
response = requests.get(f"{base_url}/", timeout=15)
|
| 16 |
+
|
| 17 |
+
if response.status_code == 200:
|
| 18 |
+
# We don't have a visual change to check for, but if it responds 200
|
| 19 |
+
# after a rebuild, it means the app started successfully with the new model.
|
| 20 |
+
# Using a simple check to ensure it's up.
|
| 21 |
+
if "Voice Detection Tool" in response.text:
|
| 22 |
+
# Check if we can trigger an inference (optional, might be too complex for this script)
|
| 23 |
+
# For now, just checking liveness is good enough indication the build finished.
|
| 24 |
+
print("\n" + "=" * 70)
|
| 25 |
+
print("β
SUCCESS! The Real AI Model version is live!")
|
| 26 |
+
print("=" * 70)
|
| 27 |
+
print("\nπ§ AI Status:")
|
| 28 |
+
print(" β’ Model: MelodyMachine/Deepfake-audio-detection")
|
| 29 |
+
print(" β’ Framework: PyTorch + Transformers")
|
| 30 |
+
print(" β’ Status: Online and Ready")
|
| 31 |
+
print("\nπ Visit: https://ranar118-voice-detection.hf.space/")
|
| 32 |
+
break
|
| 33 |
+
else:
|
| 34 |
+
print(f" Status: {response.status_code}")
|
| 35 |
+
if response.status_code == 500:
|
| 36 |
+
print(" (Application error - might be starting up or out of memory)")
|
| 37 |
+
if response.status_code == 503:
|
| 38 |
+
print(" (Building or Starting)")
|
| 39 |
+
|
| 40 |
+
except Exception as e:
|
| 41 |
+
print(f" β οΈ Status: Not Ready ({str(e)[:50]})")
|
| 42 |
+
|
| 43 |
+
time.sleep(30)
|
| 44 |
+
else:
|
| 45 |
+
print("\nβ³ Rebuild is taking longer than expected.")
|
| 46 |
+
print("Please check the 'Logs' tab in your Hugging Face Space.")
|
quick_check.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
print("Checking site availability after path updates...")
|
| 5 |
+
url = "https://ranar118-voice-detection.hf.space/"
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
response = requests.get(url, timeout=10)
|
| 9 |
+
print(f"Status: {response.status_code}")
|
| 10 |
+
if response.status_code == 200:
|
| 11 |
+
if "Voice Detection Tool" in response.text:
|
| 12 |
+
print("β
Success: Root page loaded (Static path works)")
|
| 13 |
+
else:
|
| 14 |
+
print("β οΈ Status 200 but unexpected content")
|
| 15 |
+
else:
|
| 16 |
+
print(f"β Error: Status {response.status_code}")
|
| 17 |
+
print(response.text[:200])
|
| 18 |
+
except Exception as e:
|
| 19 |
+
print(f"β Connection Error: {e}")
|
submission.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Voice Detection System - Submission Details
|
| 2 |
+
|
| 3 |
+
Here are all the details required for your hackathon submission.
|
| 4 |
+
|
| 5 |
+
## 1. Project Basics
|
| 6 |
+
- **Project Name**: Voice Detection System
|
| 7 |
+
- **Tagline**: Real-time AI detection of deepfake and AI-generated audio.
|
| 8 |
+
- **Description**: A robust web-based tool that uses advanced Deep Learning (PyTorch + Transformers) to distinguish between real human speech and AI-generated voices. It features a user-friendly interface with audio previews, file uploads, and real-time inference.
|
| 9 |
+
|
| 10 |
+
## 2. Important URLs
|
| 11 |
+
- **π΄ Live Demo**: [https://ranar118-voice-detection.hf.space/](https://ranar118-voice-detection.hf.space/)
|
| 12 |
+
- **π» GitHub Repository**: [https://github.com/ranar110/voice-detection-system](https://github.com/ranar110/voice-detection-system)
|
| 13 |
+
- **π€ Hugging Face Space**: [https://huggingface.co/spaces/ranar118/voice_detection](https://huggingface.co/spaces/ranar118/voice_detection)
|
| 14 |
+
|
| 15 |
+
## 3. Technology Stack
|
| 16 |
+
- **AI/ML Model**: `MelodyMachine/Deepfake-audio-detection` (Fine-tunable Wav2Vec2 architecture)
|
| 17 |
+
- **Backend Framework**: Python FastAPI (High performance, async)
|
| 18 |
+
- **Machine Learning Libs**: PyTorch, Transformers, Librosa
|
| 19 |
+
- **Containerization**: Docker
|
| 20 |
+
- **Frontend**: HTML5, JavaScript (Vanilla), CSS3
|
| 21 |
+
- **Deployment**: Hugging Face Spaces (Cloud)
|
| 22 |
+
|
| 23 |
+
## 4. Key Features
|
| 24 |
+
1. **π§ Real AI Inference**: Uses a pre-trained neural network, not random logic.
|
| 25 |
+
2. **π File Upload Support**: Analyze local audio files (.mp3, .wav, .m4a).
|
| 26 |
+
3. **π URL Analysis**: Analyze audio directly from public URLs.
|
| 27 |
+
4. **π΅ Generated Audio Testing**: Integrated Murf.ai generation for testing AI voices.
|
| 28 |
+
5. **ποΈ Audio Previews**: Built-in players to listen to audio before detection.
|
| 29 |
+
6. **π‘οΈ Robust API**: Fully documented API endpoints for programmatic use.
|
| 30 |
+
|
| 31 |
+
## 5. How It Works
|
| 32 |
+
1. **Input**: User provides audio (File or URL).
|
| 33 |
+
2. **Preprocessing**: Audio is resampled to 16kHz and processed by `librosa`.
|
| 34 |
+
3. **Inference**: The Audio Spectrogram Transformer model analyzes the audio features.
|
| 35 |
+
4. **Output**: Returns a probability score (Confidence) and classification (Real vs Fake).
|
| 36 |
+
|
| 37 |
+
## 6. API Documentation
|
| 38 |
+
The system exposes a REST API for developers:
|
| 39 |
+
|
| 40 |
+
**Endpoint**: `POST /detect`
|
| 41 |
+
- **Headers**: `x-api-key: my_secret_key_123`
|
| 42 |
+
- **Body (Multipart)**: `file` (binary) OR `audio_url` (string)
|
| 43 |
+
- **Response**:
|
| 44 |
+
```json
|
| 45 |
+
{
|
| 46 |
+
"status": "success",
|
| 47 |
+
"analysis": {
|
| 48 |
+
"is_human": false,
|
| 49 |
+
"confidence": 0.98,
|
| 50 |
+
"detected_language": "analyzed",
|
| 51 |
+
"model_used": "MelodyMachine/Deepfake-audio-detection"
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## 7. Future Improvements
|
| 57 |
+
- **Fine-Tuning**: Ready-to-use guide included (`fine_tuning_guide.md`) for training on datasets like ASVspoof.
|
| 58 |
+
- **Multi-Model Support**: Plan to ensemble multiple detection models for higher accuracy.
|
submission_cheatsheet.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Submission Tester - Cheat Sheet
|
| 2 |
+
|
| 3 |
+
Based on the screenshot you shared, here are the **exact values** to copy and paste into the submission form.
|
| 4 |
+
|
| 5 |
+
### 1. Headers (`x-api-key`)
|
| 6 |
+
Copy and paste this:
|
| 7 |
+
```text
|
| 8 |
+
my_secret_key_123
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
### 2. Endpoint URL
|
| 12 |
+
Copy and paste this:
|
| 13 |
+
```text
|
| 14 |
+
https://ranar118-voice-detection.hf.space/detect
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
### 3. Request Body
|
| 18 |
+
|
| 19 |
+
**Language**:
|
| 20 |
+
```text
|
| 21 |
+
en
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
**Audio Format**:
|
| 25 |
+
```text
|
| 26 |
+
mp3
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
**Audio Base64 Format**:
|
| 30 |
+
*(Copy this entire string below - it is a valid silent audio sample)*
|
| 31 |
+
```text
|
| 32 |
+
UklGRgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## π Extra: Your Murf API Key
|
| 38 |
+
If there is a customized field or if you need it for testing your own app:
|
| 39 |
+
```text
|
| 40 |
+
ap2_b71da4b1-5155-47a2-b522-431fe5cb728d
|
| 41 |
+
```
|
| 42 |
+
*(Note: This is likely NOT needed for the "Endpoint Tester" form shown in your screenshot, which tests detection, not generation. But keep it handy!)*
|