Spaces:
Sleeping
Sleeping
Update detector.py
Browse files- detector.py +9 -4
detector.py
CHANGED
|
@@ -43,13 +43,13 @@ class VocalGuardDetector:
|
|
| 43 |
DECISION_THRESHOLD = 0.50 # SAME threshold for mic and file β no source bias
|
| 44 |
|
| 45 |
def __init__(self):
|
| 46 |
-
logger.info("VocalGuard v8.
|
| 47 |
self.local_model = None
|
| 48 |
self.local_extractor = None
|
| 49 |
self.fake_idx = 0 # index of the "AI / fake" class
|
| 50 |
self.real_idx = 1 # index of the "human / real" class
|
| 51 |
self._try_load_local()
|
| 52 |
-
logger.info("VocalGuard v8.
|
| 53 |
|
| 54 |
# ββ MODEL LOADING βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 55 |
def _try_load_local(self):
|
|
@@ -57,7 +57,12 @@ class VocalGuardDetector:
|
|
| 57 |
logger.warning("torch / transformers not available β model cannot load")
|
| 58 |
return
|
| 59 |
try:
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
self.local_extractor = AutoFeatureExtractor.from_pretrained(model_id)
|
| 62 |
self.local_model = AutoModelForAudioClassification.from_pretrained(model_id)
|
| 63 |
self.local_model.eval()
|
|
@@ -258,4 +263,4 @@ class VocalGuardDetector:
|
|
| 258 |
out.append("β
Strong natural human-speech markers")
|
| 259 |
else:
|
| 260 |
out.append("β
Natural human-speech markers present")
|
| 261 |
-
return out
|
|
|
|
| 43 |
DECISION_THRESHOLD = 0.50 # SAME threshold for mic and file β no source bias
|
| 44 |
|
| 45 |
def __init__(self):
|
| 46 |
+
logger.info("VocalGuard v8.1 initializing...")
|
| 47 |
self.local_model = None
|
| 48 |
self.local_extractor = None
|
| 49 |
self.fake_idx = 0 # index of the "AI / fake" class
|
| 50 |
self.real_idx = 1 # index of the "human / real" class
|
| 51 |
self._try_load_local()
|
| 52 |
+
logger.info("VocalGuard v8.1 ready.")
|
| 53 |
|
| 54 |
# ββ MODEL LOADING βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 55 |
def _try_load_local(self):
|
|
|
|
| 57 |
logger.warning("torch / transformers not available β model cannot load")
|
| 58 |
return
|
| 59 |
try:
|
| 60 |
+
# Swapped from MelodyMachine/Deepfake-audio-detection-V2: that model's
|
| 61 |
+
# training data predates modern commercial TTS (ElevenLabs, PlayHT, etc.)
|
| 62 |
+
# and consistently missed those clips. This model's training set
|
| 63 |
+
# explicitly includes ElevenLabs, Amazon Polly, Hexgrad Kokoro, Hume AI,
|
| 64 |
+
# Speechify, and Luvvoice β a much closer match to real-world AI voices.
|
| 65 |
+
model_id = "garystafford/wav2vec2-deepfake-voice-detector"
|
| 66 |
self.local_extractor = AutoFeatureExtractor.from_pretrained(model_id)
|
| 67 |
self.local_model = AutoModelForAudioClassification.from_pretrained(model_id)
|
| 68 |
self.local_model.eval()
|
|
|
|
| 263 |
out.append("β
Strong natural human-speech markers")
|
| 264 |
else:
|
| 265 |
out.append("β
Natural human-speech markers present")
|
| 266 |
+
return out
|