Spaces:
Sleeping
Sleeping
Commit ·
afbe9ff
1
Parent(s): 92e1ae1
update for malyalam
Browse files- README.md +4 -2
- app/audio_processor.py +14 -9
- app/config.py +1 -0
- plans/api-specification.md +1 -0
README.md
CHANGED
|
@@ -156,6 +156,7 @@ The following environment variables can be configured:
|
|
| 156 |
|----------|---------|-------------|
|
| 157 |
| `API_KEY` | hackathon-2026-voice-auth-api-key | API authentication key |
|
| 158 |
| `MAX_AUDIO_SIZE_MB` | 10 | Maximum audio file size |
|
|
|
|
| 159 |
| `MAX_AUDIO_DURATION_SECONDS` | 60 | Maximum audio duration |
|
| 160 |
| `HF_ANTISPOOF_MODEL` | garystafford/wav2vec2-deepfake-voice-detector | HF model name for anti-spoofing |
|
| 161 |
| `HF_ANTISPOOF_THRESHOLD` | 0.9 | AI detection threshold |
|
|
@@ -193,8 +194,9 @@ Common HTTP status codes:
|
|
| 193 |
|
| 194 |
## Limitations
|
| 195 |
|
| 196 |
-
- Maximum audio file size: 10MB
|
| 197 |
-
-
|
|
|
|
| 198 |
- Audio format: MP3 only
|
| 199 |
- Supported languages: Tamil, English, Hindi, Malayalam, Telugu
|
| 200 |
|
|
|
|
| 156 |
|----------|---------|-------------|
|
| 157 |
| `API_KEY` | hackathon-2026-voice-auth-api-key | API authentication key |
|
| 158 |
| `MAX_AUDIO_SIZE_MB` | 10 | Maximum audio file size |
|
| 159 |
+
| `MIN_AUDIO_DURATION_SECONDS` | 5 | Minimum audio duration |
|
| 160 |
| `MAX_AUDIO_DURATION_SECONDS` | 60 | Maximum audio duration |
|
| 161 |
| `HF_ANTISPOOF_MODEL` | garystafford/wav2vec2-deepfake-voice-detector | HF model name for anti-spoofing |
|
| 162 |
| `HF_ANTISPOOF_THRESHOLD` | 0.9 | AI detection threshold |
|
|
|
|
| 194 |
|
| 195 |
## Limitations
|
| 196 |
|
| 197 |
+
- Maximum audio file size: 10MB
|
| 198 |
+
- Minimum audio duration: 5 seconds
|
| 199 |
+
- Maximum audio duration: 60 seconds
|
| 200 |
- Audio format: MP3 only
|
| 201 |
- Supported languages: Tamil, English, Hindi, Malayalam, Telugu
|
| 202 |
|
app/audio_processor.py
CHANGED
|
@@ -23,10 +23,11 @@ class AudioProcessingError(Exception):
|
|
| 23 |
class AudioProcessor:
|
| 24 |
"""Process audio from Base64 to normalized waveform."""
|
| 25 |
|
| 26 |
-
def __init__(self):
|
| 27 |
-
self.target_sample_rate = settings.TARGET_SAMPLE_RATE
|
| 28 |
-
self.max_size_mb = settings.MAX_AUDIO_SIZE_MB
|
| 29 |
-
self.max_duration_seconds = settings.MAX_AUDIO_DURATION_SECONDS
|
|
|
|
| 30 |
|
| 31 |
def decode_base64(self, base64_content: str) -> bytes:
|
| 32 |
"""
|
|
@@ -92,11 +93,15 @@ class AudioProcessor:
|
|
| 92 |
if len(audio_array.shape) > 1:
|
| 93 |
audio_array = np.mean(audio_array, axis=1)
|
| 94 |
|
| 95 |
-
duration = len(audio_array) / sample_rate
|
| 96 |
-
if duration
|
| 97 |
-
raise AudioProcessingError(
|
| 98 |
-
f"Audio too
|
| 99 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
logger.info(f"Loaded audio: {duration:.2f}s @ {sample_rate}Hz")
|
| 102 |
return audio_array, sample_rate
|
|
|
|
| 23 |
class AudioProcessor:
|
| 24 |
"""Process audio from Base64 to normalized waveform."""
|
| 25 |
|
| 26 |
+
def __init__(self):
|
| 27 |
+
self.target_sample_rate = settings.TARGET_SAMPLE_RATE
|
| 28 |
+
self.max_size_mb = settings.MAX_AUDIO_SIZE_MB
|
| 29 |
+
self.max_duration_seconds = settings.MAX_AUDIO_DURATION_SECONDS
|
| 30 |
+
self.min_duration_seconds = settings.MIN_AUDIO_DURATION_SECONDS
|
| 31 |
|
| 32 |
def decode_base64(self, base64_content: str) -> bytes:
|
| 33 |
"""
|
|
|
|
| 93 |
if len(audio_array.shape) > 1:
|
| 94 |
audio_array = np.mean(audio_array, axis=1)
|
| 95 |
|
| 96 |
+
duration = len(audio_array) / sample_rate
|
| 97 |
+
if duration < self.min_duration_seconds:
|
| 98 |
+
raise AudioProcessingError(
|
| 99 |
+
f"Audio too short: {duration:.2f}s (min {self.min_duration_seconds}s)"
|
| 100 |
+
)
|
| 101 |
+
if duration > self.max_duration_seconds:
|
| 102 |
+
raise AudioProcessingError(
|
| 103 |
+
f"Audio too long: {duration:.1f}s (max {self.max_duration_seconds}s)"
|
| 104 |
+
)
|
| 105 |
|
| 106 |
logger.info(f"Loaded audio: {duration:.2f}s @ {sample_rate}Hz")
|
| 107 |
return audio_array, sample_rate
|
app/config.py
CHANGED
|
@@ -18,6 +18,7 @@ class Settings(BaseSettings):
|
|
| 18 |
# Audio Processing
|
| 19 |
MAX_AUDIO_SIZE_MB: int = 10
|
| 20 |
MAX_AUDIO_DURATION_SECONDS: int = 60
|
|
|
|
| 21 |
TARGET_SAMPLE_RATE: int = 16000
|
| 22 |
|
| 23 |
# Model Configuration
|
|
|
|
| 18 |
# Audio Processing
|
| 19 |
MAX_AUDIO_SIZE_MB: int = 10
|
| 20 |
MAX_AUDIO_DURATION_SECONDS: int = 60
|
| 21 |
+
MIN_AUDIO_DURATION_SECONDS: int = 5
|
| 22 |
TARGET_SAMPLE_RATE: int = 16000
|
| 23 |
|
| 24 |
# Model Configuration
|
plans/api-specification.md
CHANGED
|
@@ -182,6 +182,7 @@ The API generates explanations based on detected acoustic features:
|
|
| 182 |
|
| 183 |
- **Requests per minute**: 60
|
| 184 |
- **Max audio size**: 10MB (Base64 decoded)
|
|
|
|
| 185 |
- **Max audio duration**: 60 seconds
|
| 186 |
|
| 187 |
## HTTP Status Codes
|
|
|
|
| 182 |
|
| 183 |
- **Requests per minute**: 60
|
| 184 |
- **Max audio size**: 10MB (Base64 decoded)
|
| 185 |
+
- **Min audio duration**: 5 seconds
|
| 186 |
- **Max audio duration**: 60 seconds
|
| 187 |
|
| 188 |
## HTTP Status Codes
|