Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
| 82 |
score = 100 - (critical * 30) - (high * 15) - (medium * 5)
|
| 83 |
score = max(0, score)
|
| 84 |
|
| 85 |
-
#
|
| 86 |
if score >= 90:
|
| 87 |
-
grade, quality
|
|
|
|
|
|
|
| 88 |
elif score >= 75:
|
| 89 |
-
grade, quality
|
|
|
|
|
|
|
| 90 |
elif score >= 60:
|
| 91 |
-
grade, quality
|
|
|
|
|
|
|
| 92 |
elif score >= 40:
|
| 93 |
-
grade, quality
|
|
|
|
|
|
|
| 94 |
else:
|
| 95 |
-
grade, quality
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|