VoiceGuard Bot commited on
Commit
eeaad03
·
1 Parent(s): e25843f

Optimize: Tighten Heuristic thresholds and disable dithering to fix AI false negatives

Browse files
app/core/audio_processor.py CHANGED
@@ -166,11 +166,11 @@ class AudioProcessor:
166
  # 2. Normalize Volume (Re-enabled: Necessary for consistent chunked inference)
167
  waveform = librosa.util.normalize(waveform)
168
 
169
- # 3. Dithering / Noise Injection
170
- # Real microphones have thermal noise. High-quality digital files (AAC/AI) can be "too clean" (zeros).
171
- # Adding tiny Gaussian noise prevents "perfect silence" from triggering AI detection.
172
- noise_amp = 0.005 * np.max(np.abs(waveform))
173
- waveform = waveform + noise_amp * np.random.normal(size=len(waveform))
174
 
175
  return waveform
176
 
 
166
  # 2. Normalize Volume (Re-enabled: Necessary for consistent chunked inference)
167
  waveform = librosa.util.normalize(waveform)
168
 
169
+ # 3. Dithering / Noise Injection (DISABLED)
170
+ # Reason: Dithering added noise that helped Human audio pass, but also helped High-Quality AI pass.
171
+ # We now rely on the Heuristic Override to catch compressed human audio, so we don't need to fake the noise.
172
+ # noise_amp = 0.005 * np.max(np.abs(waveform))
173
+ # waveform = waveform + noise_amp * np.random.normal(size=len(waveform))
174
 
175
  return waveform
176
 
app/core/detector.py CHANGED
@@ -316,12 +316,15 @@ class DeepfakeDetector:
316
 
317
  print(f" features: centroid_var={centroid_var:.2f}, zcr_var={zcr_var:.4f}")
318
 
319
- # Thresholds derived from analysis of 'SH 69 4.mp3' (Human) vs AI samples
320
  # Human (SH 69 4): centroid_var ~774k, zcr_var ~0.011
321
- # AI (ElevenLabs): often lower variance or very specific high-freq patterns
322
 
323
- # If BOTH are substantial, it's likely human
324
- if centroid_var > 100000 and zcr_var > 0.001:
 
 
 
325
  return True
326
 
327
  return False
 
316
 
317
  print(f" features: centroid_var={centroid_var:.2f}, zcr_var={zcr_var:.4f}")
318
 
319
+ # Thresholds tuned to distinguish "Noisy/Compressed Human" from "Clean/Hifi AI"
320
  # Human (SH 69 4): centroid_var ~774k, zcr_var ~0.011
321
+ # AI (ElevenLabs): typically lower variance (cleaner, more consistent channel)
322
 
323
+ # STAGE 2 TUNING:
324
+ # Raised zcr_var to 0.005 (was 0.001). ElevenLabs is usually < 0.005.
325
+ # Raised centroid_var to 250k (was 100k).
326
+ # This ensures only "very dynamic/noisy" recordings trigger the override.
327
+ if centroid_var > 250000 and zcr_var > 0.005:
328
  return True
329
 
330
  return False