alkvoice / README_API.md
alkasima's picture
Upload 16 files
93f5fa9 verified
|
Raw History Blame Contribute Delete
4.4 kB
---
title: AI Voice Enhancer API
emoji: πŸŽ™οΈ
colorFrom: purple
colorTo: blue
sdk: gradio
sdk_version: "5.50.0"
app_file: app_wrapper.py
pinned: false
---
# πŸŽ™οΈ AI Voice Enhancer API
Professional podcast-quality audio enhancement powered by AI. This Space provides a **REST API** for audio processing.
## πŸš€ Quick Start
### For End Users (with Frontend)
1. **Download** the frontend from the repository
2. **Open** `frontend/index.html` in your browser
3. **Configure** API URL to this Space: `https://YOUR-SPACE-NAME.hf.space`
4. **Upload** audio and enhance!
### For Developers (API Integration)
```bash
curl -X POST "https://YOUR-SPACE-NAME.hf.space/enhance" \
-F "file=@input.wav" \
-F "speech_level=80" \
-F "background_level=85" \
-o enhanced.wav
```
## πŸ“‘ API Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | API information |
| `/health` | GET | Health check |
| `/enhance` | POST | Enhance audio file |
| `/cleanup` | DELETE | Clean temp files |
## 🎚️ Parameters
### POST /enhance
- **file**: Audio file (WAV, MP3, M4A, FLAC, OGG, AAC)
- **speech_level**: 0-100 (default: 80) - Voice clarity
- **background_level**: 0-100 (default: 85) - Noise reduction
## 🎯 Features
- βœ… **Noise Suppression**: Facebook Denoiser (DNS) + FFmpeg
- βœ… **Clarity Enhancement**: Multi-stage EQ, compression, de-essing
- βœ… **Loudness Normalization**: EBU R128 standard (-16 LUFS)
- βœ… **Adjustable Processing**: Fine-tune enhancement levels
- βœ… **CPU Optimized**: Runs on free Spaces
- βœ… **CORS Enabled**: Works with any frontend
## πŸ”§ Technical Details
### Audio Processing Pipeline:
1. **Validation** - Check format, duration, file size
2. **Noise Suppression** - DNS model or FFmpeg afftdn
3. **Clarity Enhancement** - EQ, gate, compression, de-esser
4. **Normalization** - EBU R128 loudness standard
### Processing Time:
- 10-second audio: ~15-30 seconds
- 60-second audio: ~60-120 seconds
- Depends on CPU availability
## πŸ“Š Quality
Targets 80-90% of Adobe Podcast Enhance Speech quality:
| Feature | Adobe Podcast | This API |
|---------|--------------|----------|
| Noise Removal | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| Clarity | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| Speed | ⭐⭐⭐ | ⭐⭐⭐⭐ |
| Cost | πŸ’°πŸ’°πŸ’° | Free βœ… |
## πŸ’» Example: Python Client
```python
import requests
class VoiceEnhancer:
def __init__(self, api_url):
self.api_url = api_url
def enhance(self, audio_file, speech=80, background=85):
url = f"{self.api_url}/enhance"
files = {"file": open(audio_file, "rb")}
data = {
"speech_level": speech,
"background_level": background
}
response = requests.post(url, files=files, data=data)
if response.ok:
return response.content
else:
raise Exception(f"Enhancement failed: {response.text}")
# Usage
enhancer = VoiceEnhancer("https://YOUR-SPACE-NAME.hf.space")
enhanced_audio = enhancer.enhance("input.wav", speech=80, background=85)
with open("output.wav", "wb") as f:
f.write(enhanced_audio)
```
## πŸ“ Limitations
- **Duration**: Max 60 seconds
- **File Size**: Max 50MB
- **Concurrent Users**: Limited on free tier
- **Processing Speed**: Depends on CPU availability
## πŸ› οΈ Tech Stack
- **API Framework**: FastAPI + Uvicorn
- **Audio Processing**:
- PyTorch + Torchaudio
- Facebook Denoiser (DNS)
- FFmpeg (filters, normalization)
- **ML Model**: DNS64 (pretrained)
## πŸ“¦ Deployment
This Space runs:
- FastAPI server on port 7860
- Gradio info page on port 7861 (this page)
The actual audio processing happens via the FastAPI endpoints.
## πŸ”’ Privacy
- No data stored permanently
- Temporary files auto-deleted after 30 minutes
- No analytics or tracking
- Processes on-server (no external APIs)
## πŸ“„ License
MIT License - Free to use, modify, and distribute.
## πŸ™ Acknowledgments
- **Facebook AI**: For Denoiser library
- **FFmpeg**: For robust audio tools
- **Hugging Face**: For free hosting
---
**Repository**: [GitHub Link Here]
**Frontend**: Download from repository
**Support**: Open an issue on GitHub