Rthur2003 commited on
Commit
e2e6c4b
·
1 Parent(s): ecb4fb3

feat: add CLAP and FST indicators to score fusion results

Browse files
Files changed (1) hide show
  1. app/services/score_fusion.py +31 -8
app/services/score_fusion.py CHANGED
@@ -322,6 +322,8 @@ def _build_indicators(
322
  confidence: float,
323
  features: AudioFeatures,
324
  vocals: Optional[VocalFeatures],
 
 
325
  ext_mai: Optional[_ExternalScore],
326
  ext_ses: Optional[_ExternalScore],
327
  ) -> List[str]:
@@ -348,38 +350,59 @@ def _build_indicators(
348
  # Feature-specific indicators
349
  if features.spectral_regularity > 0.7:
350
  indicators.append(
351
- "Spectral patterns show high regularity typical of AI generation."
 
352
  )
353
  elif features.spectral_regularity < 0.3:
354
  indicators.append(
355
- "Spectral variation is consistent with natural human composition."
 
356
  )
357
 
358
  if features.temporal_patterns > 0.7:
359
  indicators.append(
360
  f"Temporal patterns are metronomically precise "
361
- f"(tempo stability: {features.tempo_stability:.3f}s std)."
 
362
  )
363
  elif features.temporal_patterns < 0.3:
364
  indicators.append(
365
- "Natural timing variation detected in rhythmic patterns."
 
366
  )
367
 
368
  if features.harmonic_structure > 0.7:
369
  indicators.append(
370
- "Harmonic progressions follow predictable AI-typical patterns."
 
371
  )
372
 
373
  # Vocal indicators
374
  if vocals and vocals.has_vocals:
375
  indicators.extend(vocals.indicators)
376
 
377
- # External source indicators
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  if ext_mai and ext_mai.available:
379
  label = "AI-generated" if ext_mai.is_ai else "human-composed"
380
  indicators.append(
381
- f"External Music-AI detector classified as {label} "
382
- f"({ext_mai.confidence:.1%} confidence)."
383
  )
384
 
385
  if ext_ses and ext_ses.available:
 
322
  confidence: float,
323
  features: AudioFeatures,
324
  vocals: Optional[VocalFeatures],
325
+ clap: Optional[_ExternalScore],
326
+ fst: Optional[_ExternalScore],
327
  ext_mai: Optional[_ExternalScore],
328
  ext_ses: Optional[_ExternalScore],
329
  ) -> List[str]:
 
350
  # Feature-specific indicators
351
  if features.spectral_regularity > 0.7:
352
  indicators.append(
353
+ "Spectral patterns show high regularity "
354
+ "typical of AI generation."
355
  )
356
  elif features.spectral_regularity < 0.3:
357
  indicators.append(
358
+ "Spectral variation is consistent with "
359
+ "natural human composition."
360
  )
361
 
362
  if features.temporal_patterns > 0.7:
363
  indicators.append(
364
  f"Temporal patterns are metronomically precise "
365
+ f"(tempo stability: "
366
+ f"{features.tempo_stability:.3f}s std)."
367
  )
368
  elif features.temporal_patterns < 0.3:
369
  indicators.append(
370
+ "Natural timing variation detected in "
371
+ "rhythmic patterns."
372
  )
373
 
374
  if features.harmonic_structure > 0.7:
375
  indicators.append(
376
+ "Harmonic progressions follow predictable "
377
+ "AI-typical patterns."
378
  )
379
 
380
  # Vocal indicators
381
  if vocals and vocals.has_vocals:
382
  indicators.extend(vocals.indicators)
383
 
384
+ # CLAP embedding indicator (Layer 2)
385
+ if clap and clap.available:
386
+ label = "AI-generated" if clap.is_ai else "human-composed"
387
+ indicators.append(
388
+ f"CLAP embedding analysis classified as {label} "
389
+ f"({clap.confidence:.1%} confidence)."
390
+ )
391
+
392
+ # FST indicator (Layer 3)
393
+ if fst and fst.available:
394
+ label = "AI-generated" if fst.is_ai else "human-composed"
395
+ indicators.append(
396
+ f"FST (Fusion Segment Transformer) classified as "
397
+ f"{label} ({fst.confidence:.1%} confidence)."
398
+ )
399
+
400
+ # Legacy external source indicators
401
  if ext_mai and ext_mai.available:
402
  label = "AI-generated" if ext_mai.is_ai else "human-composed"
403
  indicators.append(
404
+ f"External Music-AI detector classified as "
405
+ f"{label} ({ext_mai.confidence:.1%} confidence)."
406
  )
407
 
408
  if ext_ses and ext_ses.available: