Mr7Explorer commited on
Commit
976efb4
Β·
verified Β·
1 Parent(s): 30082c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -8
app.py CHANGED
@@ -72,27 +72,59 @@ def analyze_audio(audio_file, progress=gr.Progress()):
72
  # SCORING
73
  # ======================================================
74
  progress(0.82, desc="Scoring...")
75
-
76
  # Count issues by severity
77
  critical = sum(1 for _, sev, _ in issues if sev == "CRITICAL")
78
  high = sum(1 for _, sev, _ in issues if sev == "HIGH")
79
  medium = sum(1 for _, sev, _ in issues if sev == "MEDIUM")
 
80
 
81
- # Original scoring formula preserved exactly
82
  score = 100 - (critical * 30) - (high * 15) - (medium * 5)
83
  score = max(0, score)
84
 
85
- # QUALITY LABELS (original logic)
86
  if score >= 90:
87
- grade, quality, color = "A", "EXCELLENT", "🟒"
 
 
88
  elif score >= 75:
89
- grade, quality, color = "B", "GOOD", "🟒"
 
 
90
  elif score >= 60:
91
- grade, quality, color = "C", "FAIR", "🟑"
 
 
92
  elif score >= 40:
93
- grade, quality, color = "D", "POOR", "🟠"
 
 
94
  else:
95
- grade, quality, color = "F", "CRITICAL", "πŸ”΄"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  # ======================================================
98
  # CREATE REPORT PNG
 
72
  # SCORING
73
  # ======================================================
74
  progress(0.82, desc="Scoring...")
75
+
76
  # Count issues by severity
77
  critical = sum(1 for _, sev, _ in issues if sev == "CRITICAL")
78
  high = sum(1 for _, sev, _ in issues if sev == "HIGH")
79
  medium = sum(1 for _, sev, _ in issues if sev == "MEDIUM")
80
+ low = sum(1 for _, sev, _ in issues if sev == "LOW")
81
 
82
+ # Score formula
83
  score = 100 - (critical * 30) - (high * 15) - (medium * 5)
84
  score = max(0, score)
85
 
86
+ # Grade + Quality Label (same logic as your report)
87
  if score >= 90:
88
+ grade, quality = "A", "EXCELLENT"
89
+ color = "🟒"
90
+ recommendation = "Excellent for TTS dataset"
91
  elif score >= 75:
92
+ grade, quality = "B", "GOOD"
93
+ color = "🟒"
94
+ recommendation = "Very good quality; suitable for TTS"
95
  elif score >= 60:
96
+ grade, quality = "C", "FAIR"
97
+ color = "🟑"
98
+ recommendation = "Usable but may contain processing artifacts"
99
  elif score >= 40:
100
+ grade, quality = "D", "POOR"
101
+ color = "🟠"
102
+ recommendation = "Not recommended for TTS (heavy processing)"
103
  else:
104
+ grade, quality = "F", "CRITICAL"
105
+ color = "πŸ”΄"
106
+ recommendation = "Severely degraded or processed; avoid for TTS"
107
+
108
+ # Cleanliness score (needed by report_generator)
109
+ cleanliness_score = max(0, 100 - (medium * 5 + low * 3))
110
+
111
+ # Processing severity index (needed by report_generator)
112
+ processing_severity = (critical * 3) + (high * 2) + medium
113
+
114
+ audio_data["score"] = {
115
+ "score": score,
116
+ "grade": grade,
117
+ "quality": quality,
118
+ "recommendation": recommendation,
119
+ "cleanliness_score": cleanliness_score,
120
+ "processing_severity": processing_severity,
121
+ "critical": critical,
122
+ "high": high,
123
+ "medium": medium,
124
+ "low": low,
125
+ "color": color
126
+ }
127
+
128
 
129
  # ======================================================
130
  # CREATE REPORT PNG