File size: 4,396 Bytes
93f5fa9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---

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