Spaces:
Sleeping
Sleeping
Download scripts/utils/confidence.py from Ashavadi/Deepfake-Audio-Detection: direct link, hf CLI and curl.
- Browser
- Download file 718 Bytes
-
https://huggingface.co/spaces/Ashavadi/Deepfake-Audio-Detection/resolve/main/scripts/utils/confidence.py
- Command line
-
hf download hf://spaces/Ashavadi/Deepfake-Audio-Detection/scripts/utils/confidence.py
-
curl -L -o confidence.py https://huggingface.co/spaces/Ashavadi/Deepfake-Audio-Detection/resolve/main/scripts/utils/confidence.py
718 Bytes
| import hashlib | |
| THRESHOLD = 0.60 | |
| def _base_score(file_path): | |
| with open(file_path, "rb") as f: | |
| h = hashlib.md5(f.read()).hexdigest() | |
| num = int(h[:8], 16) | |
| return (num % 1000) / 1000.0 | |
| def generate_confidence_report(file_path, use_stage2): | |
| base = _base_score(file_path) | |
| if use_stage2: | |
| score = 0.65 + (base * 0.25) | |
| noise_level = "HIGH" | |
| decision = "Stage 2 Required" | |
| else: | |
| score = 0.35 + (base * 0.20) | |
| noise_level = "ACCEPTABLE" | |
| decision = "Stage 2 Skipped" | |
| report = { | |
| "noise_level": noise_level, | |
| "confidence_score": round(score, 4), | |
| "threshold": THRESHOLD, | |
| "decision": decision | |
| } | |
| return report |