Download backend/app/utils/samples.py from vipan-kumar/Audio_Deepfake_Detection: direct link, hf CLI and curl.
- Browser
- Download file 2.14 kB
-
https://huggingface.co/spaces/vipan-kumar/Audio_Deepfake_Detection/resolve/main/backend/app/utils/samples.py
- Command line
-
hf download hf://spaces/vipan-kumar/Audio_Deepfake_Detection/backend/app/utils/samples.py
-
curl -L -o samples.py https://huggingface.co/spaces/vipan-kumar/Audio_Deepfake_Detection/resolve/main/backend/app/utils/samples.py
2.14 kB
| """Sample audio registry served from /api/samples.""" | |
| from __future__ import annotations | |
| from pathlib import Path | |
| from typing import Dict, List | |
| from app.config import settings | |
| SAMPLES: List[Dict[str, str]] = [ | |
| { | |
| "sample_id": "real_news_excerpt", | |
| "filename": "real_news_excerpt.wav", | |
| "label": "real", | |
| "description": "Natural broadcast news clip — clean studio environment.", | |
| }, | |
| { | |
| "sample_id": "real_conversation", | |
| "filename": "real_conversation.wav", | |
| "label": "real", | |
| "description": "Spontaneous conversational speech — disfluencies present.", | |
| }, | |
| { | |
| "sample_id": "real_lecture", | |
| "filename": "real_lecture.wav", | |
| "label": "real", | |
| "description": "Academic lecture segment — male speaker, room acoustics.", | |
| }, | |
| { | |
| "sample_id": "fake_tts_commercial", | |
| "filename": "fake_tts_commercial.wav", | |
| "label": "fake", | |
| "description": "Commercial-grade TTS (Eleven Labs-style synthesis).", | |
| }, | |
| { | |
| "sample_id": "fake_voice_clone", | |
| "filename": "fake_voice_clone.wav", | |
| "label": "fake", | |
| "description": "Few-shot voice conversion clone of a target speaker.", | |
| }, | |
| { | |
| "sample_id": "fake_neural_tts", | |
| "filename": "fake_neural_tts.wav", | |
| "label": "fake", | |
| "description": "High-naturalness neural TTS with prosodic variation.", | |
| }, | |
| ] | |
| def sample_dir() -> Path: | |
| """Resolve the canonical sample-audio directory.""" | |
| candidates = [ | |
| settings.project_root.parent / "data" / "sample_audios", | |
| Path("/app/data/sample_audios"), | |
| settings.project_root / "data" / "sample_audios", | |
| ] | |
| for p in candidates: | |
| if p.exists() or p.parent.exists(): | |
| return p | |
| return candidates[0] | |
| def sample_path(filename: str) -> Path: | |
| """Resolve sample file under the canonical sample directory.""" | |
| return sample_dir() / filename | |
| def sample_by_id(sample_id: str) -> Dict[str, str] | None: | |
| for s in SAMPLES: | |
| if s["sample_id"] == sample_id: | |
| return s | |
| return None | |