Spaces:
Sleeping

boobalanit commited on
Commit
a2edc68
Β·
1 Parent(s): a0178bc

feat: overhaul UI with executive dark glassmorphism and fix multi-format file parser

Browse files
Files changed (1) hide show
  1. app.py +265 -79
app.py CHANGED
@@ -26,6 +26,17 @@ from splitsafe.scan import (
26
  )
27
 
28
 
 
 
 
 
 
 
 
 
 
 
 
29
  def generate_sample_tone(freq: float, duration: float = 3.0, sr: int = 16000) -> np.ndarray:
30
  """Generate harmonic synthetic speech-like tone."""
31
  t = np.linspace(0, duration, int(sr * duration), endpoint=False)
@@ -38,23 +49,33 @@ def generate_sample_tone(freq: float, duration: float = 3.0, sr: int = 16000) ->
38
  def audit_splits(train_files, test_files, speaker_regex, min_votes, strict_speakers):
39
  """Audit user-provided audio files across split boundaries."""
40
  if not train_files or not test_files:
41
- return "⚠️ Error: Please provide at least one audio file in Train Split and one in Test Split.", ""
 
 
 
 
 
 
42
 
43
  with tempfile.TemporaryDirectory() as tmpdir:
44
  train_dir = Path(tmpdir) / "train"
45
  test_dir = Path(tmpdir) / "test"
46
- train_dir.mkdir()
47
- test_dir.mkdir()
48
 
49
- # Save train files
50
  for f in train_files:
51
- dest = train_dir / Path(f.name).name
52
- shutil.copyfile(f.name, dest)
 
 
53
 
54
- # Save test files
55
  for f in test_files:
56
- dest = test_dir / Path(f.name).name
57
- shutil.copyfile(f.name, dest)
 
 
58
 
59
  items = items_from_folders([train_dir, test_dir], ["train", "test"])
60
  if speaker_regex and speaker_regex.strip():
@@ -64,20 +85,70 @@ def audit_splits(train_files, test_files, speaker_regex, min_votes, strict_speak
64
  verdict = res.verdict(strict_speakers=strict_speakers)
65
  text_report = to_text(res, strict_speakers=strict_speakers)
66
 
67
- # Build Markdown summary card
68
- status_color = "🟒 PASS" if verdict == "PASS" else ("🟑 WARN" if verdict == "WARN" else "πŸ”΄ FAIL")
69
- summary_md = f"### Overall Verdict: {status_color}\n\n"
70
- summary_md += f"* **Train Split Files:** {len(train_files)}\n"
71
- summary_md += f"* **Test Split Files:** {len(test_files)}\n"
72
- summary_md += f"* **Cross-Split Leaks Found:** {len(res.matches)} pairs ({len(res.leaked_files)} files)\n"
73
- summary_md += f"* **Shared Speakers:** {len(res.shared_speakers)}\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  if res.matches:
76
- summary_md += "\n#### 🚨 Detected Contaminated Pairs:\n"
 
 
 
77
  for m in res.matches:
78
- summary_md += f"- **{m.a}** βž” **{m.b}** ({m.kind}, matches: {m.votes}, overlap: {m.coverage:.0%})\n"
 
 
 
 
 
 
 
 
 
79
 
80
- return summary_md, text_report
 
81
 
82
 
83
  @spaces.GPU
@@ -86,8 +157,8 @@ def run_demo_benchmark():
86
  with tempfile.TemporaryDirectory() as tmpdir:
87
  train_dir = Path(tmpdir) / "train"
88
  test_dir = Path(tmpdir) / "test"
89
- train_dir.mkdir()
90
- test_dir.mkdir()
91
 
92
  sr = 16000
93
  # Clean file in train
@@ -115,46 +186,131 @@ def run_demo_benchmark():
115
  verdict = res.verdict(strict_speakers=False)
116
  text_report = to_text(res, strict_speakers=False)
117
 
118
- summary_md = "### Demo Benchmark Run (Synthetic Audio)\n\n"
119
- summary_md += f"**Verdict:** πŸ”΄ **{verdict}** (Dataset Contaminated!)\n\n"
120
- summary_md += "* **Train Files:** 2 (`spk1_clean_take.wav`, `spk2_clean_take.wav`)\n"
121
- summary_md += "* **Test Files:** 3 (`spk3_test_unseen.wav`, `leaked_resampled_spk1.wav`, `leaked_clip_spk2.wav`)\n\n"
122
- summary_md += "#### πŸ” Caught Cross-Split Leaks:\n"
 
 
 
 
 
 
123
  for m in res.matches:
124
- summary_md += f"- **{m.a}** <-> **{m.b}** | Aligned votes: `{m.votes}`, Overlap: `{m.coverage:.0%}`\n"
125
-
126
- summary_md += "\n*(Notice how standard MD5 checksums fail on resampled audio and sub-clips, but SplitSafe catches both with 100% precision!)*"
127
- return summary_md, text_report
128
-
129
-
130
- # Build Gradio 5 UI
131
- theme = gr.themes.Soft(
132
- primary_hue="emerald",
133
- neutral_hue="slate",
134
- font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "sans-serif"],
135
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
  with gr.Blocks(title="SplitSafe β€” Audio ML Dataset Leakage Auditor") as demo:
138
- gr.Markdown(
139
  """
140
- # πŸ›‘οΈ SplitSafe: Audio ML Dataset Leakage Auditor
141
- **Guaranteed zero evaluation contamination for Speech, Voice Cloning, and Audio AI Models.**
142
- *By Boobalan Arjunan ([boobalan.it@gmail.com](mailto:boobalan.it@gmail.com)) | Open Source on [GitHub](https://github.com/BoobalanArjunan/splitsafe) & [PyPI](https://pypi.org/project/splitsafe/)*
143
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  """
145
  )
146
 
147
  with gr.Tab("πŸ“ Interactive Split Auditor"):
148
- gr.Markdown("Upload audio files to compare your **Train** and **Test/Validation** splits for data leakage.")
 
 
 
 
 
149
  with gr.Row():
150
- train_input = gr.File(label="Split A (e.g. Train Folder)", file_count="multiple", type="filepath")
151
- test_input = gr.File(label="Split B (e.g. Test / Val Folder)", file_count="multiple", type="filepath")
152
 
153
- with gr.Accordion("βš™οΈ Advanced Audit Settings", open=False):
154
  speaker_regex_input = gr.Textbox(
155
- label="Speaker Extraction Regex",
156
  placeholder=r"^[^/]+/(\d+)/",
157
- info=r"Regex with one capture group extracting speaker ID (e.g. `(spk\d+)`)",
158
  )
159
  min_votes_slider = gr.Slider(
160
  label="Minimum Aligned Votes Threshold",
@@ -162,17 +318,17 @@ with gr.Blocks(title="SplitSafe β€” Audio ML Dataset Leakage Auditor") as demo:
162
  maximum=100,
163
  value=DEFAULT_MIN_VOTES,
164
  step=5,
165
- info="Default 30 is calibrated on LibriSpeech benchmarks.",
166
  )
167
  strict_speakers_checkbox = gr.Checkbox(
168
  label="Strict Speakers Mode (Treat shared speakers as FAIL)",
169
- value=False,
170
- info="Recommended for voice cloning and speaker verification datasets.",
171
  )
172
 
173
- audit_btn = gr.Button("πŸ” Audit Dataset Splits Now", variant="primary")
174
- audit_summary = gr.Markdown(label="Audit Summary")
175
- audit_raw = gr.Code(label="Full Audit Log Report", language="markdown")
176
 
177
  audit_btn.click(
178
  fn=audit_splits,
@@ -183,12 +339,12 @@ with gr.Blocks(title="SplitSafe β€” Audio ML Dataset Leakage Auditor") as demo:
183
  with gr.Tab("⚑ 1-Click Interactive Demo"):
184
  gr.Markdown(
185
  """
186
- Test SplitSafe instantly without uploading your own files.
187
- Click below to generate a synthetic audio split containing planted resampled copies and trimmed excerpts:
188
  """
189
  )
190
- demo_btn = gr.Button("πŸš€ Run Synthetic Leakage Simulation", variant="primary")
191
- demo_summary = gr.Markdown()
192
  demo_raw = gr.Code(label="CLI Output Log", language="markdown")
193
 
194
  demo_btn.click(
@@ -198,32 +354,62 @@ with gr.Blocks(title="SplitSafe β€” Audio ML Dataset Leakage Auditor") as demo:
198
  )
199
 
200
  with gr.Tab("πŸ“Š LibriSpeech Real-World Benchmark"):
201
- gr.Markdown(
202
  """
203
- ### Empirical Benchmark on LibriSpeech (`dev-clean` vs `test-clean`)
204
- * **Files Audited:** 5,323 real human speech recordings
205
- * **False Alarms:** **0 (100% Specificity)**
206
- * **Planted Leaks Found:** **56 of 56 (100% Recall)**
207
- * **Audit Time:** **55 seconds** on a single laptop CPU (Zero GPU requirement)
208
-
209
- | Transformation Kind | Planted | Found | Missed | Detection Rate |
210
- | :--- | :--- | :--- | :--- | :--- |
211
- | Exact Duplicate | 10 | 10 | 0 | **100%** |
212
- | Resampled 11 kHz | 10 | 10 | 0 | **100%** |
213
- | Quieter (-12 dB) | 10 | 10 | 0 | **100%** |
214
- | Trimmed 20% | 10 | 10 | 0 | **100%** |
215
- | Noisy (~20dB SNR) | 10 | 10 | 0 | **100%** |
216
- | 3-Second Excerpt | 6 | 6 | 0 | **100%** |
217
- | **OVERALL TOTAL** | **56** | **56** | **0** | **100.0%** |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  """
219
  )
220
 
221
- gr.Markdown(
222
  """
223
- ---
224
- πŸ’‘ *Install locally for CI/CD pipelines:* `pip install splitsafe` | *Run CLI:* `splitsafe check train/ test/`
 
225
  """
226
  )
227
 
228
  if __name__ == "__main__":
229
- demo.launch()
 
26
  )
27
 
28
 
29
+ def _get_file_path(f) -> str:
30
+ """Robustly extract local file path whether input is string, dict, or object."""
31
+ if isinstance(f, str):
32
+ return f
33
+ if hasattr(f, "name"):
34
+ return f.name
35
+ if isinstance(f, dict) and "path" in f:
36
+ return f["path"]
37
+ return str(f)
38
+
39
+
40
  def generate_sample_tone(freq: float, duration: float = 3.0, sr: int = 16000) -> np.ndarray:
41
  """Generate harmonic synthetic speech-like tone."""
42
  t = np.linspace(0, duration, int(sr * duration), endpoint=False)
 
49
  def audit_splits(train_files, test_files, speaker_regex, min_votes, strict_speakers):
50
  """Audit user-provided audio files across split boundaries."""
51
  if not train_files or not test_files:
52
+ empty_html = """
53
+ <div style="background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); padding: 18px; border-radius: 12px; margin-top: 15px;">
54
+ <h4 style="color: #ef4444; margin: 0 0 6px 0; font-size: 16px;">⚠️ Missing Files</h4>
55
+ <p style="color: #fca5a5; margin: 0; font-size: 14px;">Please upload at least one audio file into <strong>Split A</strong> and one into <strong>Split B</strong> to perform the cross-split audit.</p>
56
+ </div>
57
+ """
58
+ return empty_html, ""
59
 
60
  with tempfile.TemporaryDirectory() as tmpdir:
61
  train_dir = Path(tmpdir) / "train"
62
  test_dir = Path(tmpdir) / "test"
63
+ train_dir.mkdir(parents=True, exist_ok=True)
64
+ test_dir.mkdir(parents=True, exist_ok=True)
65
 
66
+ # Robustly copy train files
67
  for f in train_files:
68
+ src_path = Path(_get_file_path(f))
69
+ if src_path.exists():
70
+ dest = train_dir / src_path.name
71
+ shutil.copyfile(src_path, dest)
72
 
73
+ # Robustly copy test files
74
  for f in test_files:
75
+ src_path = Path(_get_file_path(f))
76
+ if src_path.exists():
77
+ dest = test_dir / src_path.name
78
+ shutil.copyfile(src_path, dest)
79
 
80
  items = items_from_folders([train_dir, test_dir], ["train", "test"])
81
  if speaker_regex and speaker_regex.strip():
 
85
  verdict = res.verdict(strict_speakers=strict_speakers)
86
  text_report = to_text(res, strict_speakers=strict_speakers)
87
 
88
+ if verdict == "PASS":
89
+ verdict_badge = '<span style="background: linear-gradient(135deg, #10b981, #059669); color: white; padding: 6px 14px; border-radius: 9999px; font-weight: 700; font-size: 14px; letter-spacing: 0.05em; display: inline-flex; align-items: center; gap: 6px;">🟒 PASS &mdash; NO LEAKAGE DETECTED</span>'
90
+ border_color = "rgba(16, 185, 129, 0.4)"
91
+ bg_color = "rgba(16, 185, 129, 0.08)"
92
+ headline = "Your dataset splits are clean and ready for ML training!"
93
+ elif verdict == "WARN":
94
+ verdict_badge = '<span style="background: linear-gradient(135deg, #f59e0b, #d97706); color: white; padding: 6px 14px; border-radius: 9999px; font-weight: 700; font-size: 14px; letter-spacing: 0.05em; display: inline-flex; align-items: center; gap: 6px;">🟑 WARN &mdash; SHARED SPEAKERS DETECTED</span>'
95
+ border_color = "rgba(245, 158, 11, 0.4)"
96
+ bg_color = "rgba(245, 158, 11, 0.08)"
97
+ headline = "Shared speakers found across splits. Verify if your downstream model allows speaker overlap."
98
+ else:
99
+ verdict_badge = '<span style="background: linear-gradient(135deg, #ef4444, #dc2626); color: white; padding: 6px 14px; border-radius: 9999px; font-weight: 700; font-size: 14px; letter-spacing: 0.05em; display: inline-flex; align-items: center; gap: 6px;">πŸ”΄ FAIL &mdash; DATA LEAKAGE DETECTED</span>'
100
+ border_color = "rgba(239, 68, 68, 0.4)"
101
+ bg_color = "rgba(239, 68, 68, 0.08)"
102
+ headline = "CRITICAL: The exact same recording sits on both sides of your split! Training on this data will produce fake benchmarks."
103
+
104
+ # Premium HTML Card
105
+ html = f"""
106
+ <div style="background: {bg_color}; border: 1px solid {border_color}; border-radius: 16px; padding: 24px; margin-top: 15px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);">
107
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
108
+ <h3 style="margin: 0; color: #f8fafc; font-size: 20px; font-weight: 700;">Executive Audit Summary</h3>
109
+ {verdict_badge}
110
+ </div>
111
+ <p style="color: #cbd5e1; font-size: 14px; margin: 0 0 20px 0; line-height: 1.5;">{headline}</p>
112
+
113
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px;">
114
+ <div style="background: rgba(15, 23, 42, 0.6); padding: 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.05);">
115
+ <div style="color: #94a3b8; font-size: 12px; text-transform: uppercase; font-weight: 600;">Split A (Train)</div>
116
+ <div style="color: #f1f5f9; font-size: 22px; font-weight: 700; margin-top: 4px;">{len(train_files)} files</div>
117
+ </div>
118
+ <div style="background: rgba(15, 23, 42, 0.6); padding: 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.05);">
119
+ <div style="color: #94a3b8; font-size: 12px; text-transform: uppercase; font-weight: 600;">Split B (Test)</div>
120
+ <div style="color: #f1f5f9; font-size: 22px; font-weight: 700; margin-top: 4px;">{len(test_files)} files</div>
121
+ </div>
122
+ <div style="background: rgba(15, 23, 42, 0.6); padding: 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.05);">
123
+ <div style="color: #94a3b8; font-size: 12px; text-transform: uppercase; font-weight: 600;">Leaked Pairs</div>
124
+ <div style="color: {'#ef4444' if len(res.matches) > 0 else '#10b981'}; font-size: 22px; font-weight: 700; margin-top: 4px;">{len(res.matches)} pair(s)</div>
125
+ </div>
126
+ <div style="background: rgba(15, 23, 42, 0.6); padding: 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.05);">
127
+ <div style="color: #94a3b8; font-size: 12px; text-transform: uppercase; font-weight: 600;">Contaminated Files</div>
128
+ <div style="color: {'#ef4444' if len(res.leaked_files) > 0 else '#10b981'}; font-size: 22px; font-weight: 700; margin-top: 4px;">{len(res.leaked_files)} files</div>
129
+ </div>
130
+ </div>
131
+ """
132
 
133
  if res.matches:
134
+ html += """
135
+ <h4 style="color: #f8fafc; font-size: 15px; margin: 18px 0 10px 0; font-weight: 600;">🚨 Exact Contaminated File Matches:</h4>
136
+ <div style="max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;">
137
+ """
138
  for m in res.matches:
139
+ html += f"""
140
+ <div style="background: rgba(15, 23, 42, 0.7); border-left: 4px solid #ef4444; padding: 10px 14px; border-radius: 6px; font-family: monospace; font-size: 13px;">
141
+ <div style="color: #f1f5f9; display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px;">
142
+ <span><strong>{m.a}</strong> &harr; <strong>{m.b}</strong></span>
143
+ <span style="background: rgba(239, 68, 68, 0.2); color: #fca5a5; padding: 2px 8px; border-radius: 4px; font-size: 11px;">{m.votes} votes ({m.coverage:.0%} overlap)</span>
144
+ </div>
145
+ <div style="color: #94a3b8; font-size: 11px;">Kind: {m.kind}</div>
146
+ </div>
147
+ """
148
+ html += "</div>"
149
 
150
+ html += "</div>"
151
+ return html, text_report
152
 
153
 
154
  @spaces.GPU
 
157
  with tempfile.TemporaryDirectory() as tmpdir:
158
  train_dir = Path(tmpdir) / "train"
159
  test_dir = Path(tmpdir) / "test"
160
+ train_dir.mkdir(parents=True, exist_ok=True)
161
+ test_dir.mkdir(parents=True, exist_ok=True)
162
 
163
  sr = 16000
164
  # Clean file in train
 
186
  verdict = res.verdict(strict_speakers=False)
187
  text_report = to_text(res, strict_speakers=False)
188
 
189
+ demo_html = f"""
190
+ <div style="background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.4); border-radius: 16px; padding: 24px; margin-top: 15px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);">
191
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;">
192
+ <h3 style="margin: 0; color: #f8fafc; font-size: 20px; font-weight: 700;">Synthetic Benchmark Run</h3>
193
+ <span style="background: linear-gradient(135deg, #ef4444, #dc2626); color: white; padding: 6px 14px; border-radius: 9999px; font-weight: 700; font-size: 14px;">πŸ”΄ FAIL &mdash; LEAKS CAUGHT</span>
194
+ </div>
195
+ <p style="color: #cbd5e1; font-size: 14px; margin-bottom: 18px;">
196
+ SplitSafe generated 5 audio files with disguised copies. Standard MD5 checksums fail on resampled audio and sub-clips, but SplitSafe caught 100% of the planted leaks!
197
+ </p>
198
+ <div style="display: flex; flex-direction: column; gap: 8px;">
199
+ """
200
  for m in res.matches:
201
+ demo_html += f"""
202
+ <div style="background: rgba(15, 23, 42, 0.7); border-left: 4px solid #ef4444; padding: 10px 14px; border-radius: 6px; font-family: monospace; font-size: 13px;">
203
+ <div style="color: #f1f5f9; display: flex; justify-content: space-between; align-items: center;">
204
+ <span><strong>{m.a}</strong> &harr; <strong>{m.b}</strong></span>
205
+ <span style="background: rgba(239, 68, 68, 0.2); color: #fca5a5; padding: 2px 8px; border-radius: 4px; font-size: 11px;">{m.votes} votes ({m.coverage:.0%} overlap)</span>
206
+ </div>
207
+ </div>
208
+ """
209
+ demo_html += "</div></div>"
210
+ return demo_html, text_report
211
+
212
+
213
+ # Custom CSS for Sleek Dark Glassmorphic Design
214
+ custom_css = """
215
+ /* Background & Global Typography */
216
+ .gradio-container {
217
+ max-width: 1180px !important;
218
+ margin: 0 auto !important;
219
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
220
+ }
221
+
222
+ /* Primary Audit Button - Glowing Gradient */
223
+ #audit_btn {
224
+ background: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #c2410c 100%) !important;
225
+ border: none !important;
226
+ color: white !important;
227
+ font-size: 16px !important;
228
+ font-weight: 700 !important;
229
+ letter-spacing: 0.02em !important;
230
+ padding: 14px 28px !important;
231
+ border-radius: 12px !important;
232
+ box-shadow: 0 4px 18px rgba(234, 88, 12, 0.4) !important;
233
+ transition: all 0.2s ease-in-out !important;
234
+ }
235
+
236
+ #audit_btn:hover {
237
+ transform: translateY(-2px) !important;
238
+ box-shadow: 0 6px 24px rgba(234, 88, 12, 0.6) !important;
239
+ }
240
+
241
+ #demo_btn {
242
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
243
+ border: none !important;
244
+ color: white !important;
245
+ font-size: 16px !important;
246
+ font-weight: 700 !important;
247
+ padding: 14px 28px !important;
248
+ border-radius: 12px !important;
249
+ box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35) !important;
250
+ transition: all 0.2s ease-in-out !important;
251
+ }
252
+
253
+ #demo_btn:hover {
254
+ transform: translateY(-2px) !important;
255
+ box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5) !important;
256
+ }
257
+
258
+ /* Dark Card Borders & Tabs */
259
+ .tab-nav button {
260
+ font-size: 15px !important;
261
+ font-weight: 600 !important;
262
+ padding: 10px 20px !important;
263
+ }
264
+ """
265
 
266
  with gr.Blocks(title="SplitSafe β€” Audio ML Dataset Leakage Auditor") as demo:
267
+ gr.HTML(
268
  """
269
+ <div style="background: linear-gradient(180deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.8) 100%); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 20px; padding: 32px; margin-bottom: 24px; text-align: center; box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);">
270
+ <div style="display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; background: rgba(234, 88, 12, 0.15); border: 1px solid rgba(234, 88, 12, 0.4); border-radius: 16px; margin-bottom: 16px; font-size: 32px;">
271
+ πŸ›‘οΈ
272
+ </div>
273
+ <h1 style="color: #f8fafc; font-size: 32px; font-weight: 800; margin: 0 0 10px 0; letter-spacing: -0.02em;">
274
+ SplitSafe <span style="background: linear-gradient(135deg, #f97316, #fb923c); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">Auditor</span>
275
+ </h1>
276
+ <p style="color: #94a3b8; font-size: 16px; max-width: 680px; margin: 0 auto 18px auto; line-height: 1.6;">
277
+ Guarantee <strong>zero evaluation contamination</strong> before model training. Catches exact, resampled, trimmed, and sub-clip duplicates across splits in seconds.
278
+ </p>
279
+ <div style="display: flex; justify-content: center; gap: 12px; flex-wrap: wrap;">
280
+ <span style="background: rgba(255, 255, 255, 0.05); color: #cbd5e1; padding: 6px 14px; border-radius: 9999px; font-size: 13px; font-weight: 500; border: 1px solid rgba(255, 255, 255, 0.1);">
281
+ πŸ‘€ Author: <strong>Boobalan Arjunan</strong>
282
+ </span>
283
+ <a href="https://github.com/BoobalanArjunan/splitsafe" target="_blank" style="text-decoration: none;">
284
+ <span style="background: rgba(30, 41, 59, 0.8); color: #38bdf8; padding: 6px 14px; border-radius: 9999px; font-size: 13px; font-weight: 600; border: 1px solid rgba(56, 189, 248, 0.3);">
285
+ πŸ™ GitHub Repository &rarr;
286
+ </span>
287
+ </a>
288
+ <a href="https://pypi.org/project/splitsafe/" target="_blank" style="text-decoration: none;">
289
+ <span style="background: rgba(30, 41, 59, 0.8); color: #a855f7; padding: 6px 14px; border-radius: 9999px; font-size: 13px; font-weight: 600; border: 1px solid rgba(168, 85, 247, 0.3);">
290
+ πŸ“¦ PyPI Package &rarr;
291
+ </span>
292
+ </a>
293
+ </div>
294
+ </div>
295
  """
296
  )
297
 
298
  with gr.Tab("πŸ“ Interactive Split Auditor"):
299
+ gr.Markdown(
300
+ """
301
+ **Step 1:** Upload your audio files into **Split A** (e.g. `train`) and **Split B** (e.g. `test` or `val`).
302
+ **Step 2:** Click the button below to execute deterministic spectral-peak landmark matching across splits.
303
+ """
304
+ )
305
  with gr.Row():
306
+ train_input = gr.File(label="πŸ“‚ Split A (e.g. Train Folder)", file_count="multiple", type="filepath")
307
+ test_input = gr.File(label="πŸ“‚ Split B (e.g. Test / Val Folder)", file_count="multiple", type="filepath")
308
 
309
+ with gr.Accordion("βš™οΈ Advanced Detection Settings & Speaker Filtering", open=False):
310
  speaker_regex_input = gr.Textbox(
311
+ label="Speaker Identity Extraction Regex",
312
  placeholder=r"^[^/]+/(\d+)/",
313
+ info=r"Regex with ONE capture group extracting speaker ID (e.g. `^[^/]+/([^_]+)_`)",
314
  )
315
  min_votes_slider = gr.Slider(
316
  label="Minimum Aligned Votes Threshold",
 
318
  maximum=100,
319
  value=DEFAULT_MIN_VOTES,
320
  step=5,
321
+ info="Default 30 is empirically validated on 5,323 LibriSpeech files with 0 false alarms.",
322
  )
323
  strict_speakers_checkbox = gr.Checkbox(
324
  label="Strict Speakers Mode (Treat shared speakers as FAIL)",
325
+ value=True,
326
+ info="Mandatory for Voice Cloning, TTS, and Speaker Verification datasets.",
327
  )
328
 
329
+ audit_btn = gr.Button("πŸ” Audit Dataset Splits Now", elem_id="audit_btn", variant="primary")
330
+ audit_summary = gr.HTML()
331
+ audit_raw = gr.Code(label="Terminal Audit Report (CLI Format)", language="markdown")
332
 
333
  audit_btn.click(
334
  fn=audit_splits,
 
339
  with gr.Tab("⚑ 1-Click Interactive Demo"):
340
  gr.Markdown(
341
  """
342
+ Don't have dataset files handy right now? Test SplitSafe's detection engine with 1 click!
343
+ This simulation generates synthetic voice takes with planted resampled copies and trimmed sub-clips:
344
  """
345
  )
346
+ demo_btn = gr.Button("πŸš€ Run Synthetic Leakage Simulation", elem_id="demo_btn", variant="primary")
347
+ demo_summary = gr.HTML()
348
  demo_raw = gr.Code(label="CLI Output Log", language="markdown")
349
 
350
  demo_btn.click(
 
354
  )
355
 
356
  with gr.Tab("πŸ“Š LibriSpeech Real-World Benchmark"):
357
+ gr.HTML(
358
  """
359
+ <div style="background: rgba(15, 23, 42, 0.7); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px; padding: 24px;">
360
+ <h3 style="color: #f8fafc; margin-top: 0; font-size: 20px;">Empirical Benchmark on LibriSpeech (dev-clean vs test-clean)</h3>
361
+ <p style="color: #94a3b8; font-size: 14px; margin-bottom: 20px;">
362
+ SplitSafe was benchmarked on <strong>5,323 official human speech recordings</strong> across <code>dev-clean</code> and <code>test-clean</code> splits:
363
+ </p>
364
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px;">
365
+ <div style="background: rgba(30, 41, 59, 0.6); padding: 14px; border-radius: 10px;">
366
+ <div style="color: #94a3b8; font-size: 12px; text-transform: uppercase;">Total Files Audited</div>
367
+ <div style="color: #f1f5f9; font-size: 22px; font-weight: 700; margin-top: 4px;">5,323 files</div>
368
+ </div>
369
+ <div style="background: rgba(30, 41, 59, 0.6); padding: 14px; border-radius: 10px;">
370
+ <div style="color: #94a3b8; font-size: 12px; text-transform: uppercase;">False Alarms</div>
371
+ <div style="color: #10b981; font-size: 22px; font-weight: 700; margin-top: 4px;">0 (100% Clean)</div>
372
+ </div>
373
+ <div style="background: rgba(30, 41, 59, 0.6); padding: 14px; border-radius: 10px;">
374
+ <div style="color: #94a3b8; font-size: 12px; text-transform: uppercase;">Planted Leaks Found</div>
375
+ <div style="color: #10b981; font-size: 22px; font-weight: 700; margin-top: 4px;">56 of 56 (100%)</div>
376
+ </div>
377
+ <div style="background: rgba(30, 41, 59, 0.6); padding: 14px; border-radius: 10px;">
378
+ <div style="color: #94a3b8; font-size: 12px; text-transform: uppercase;">Audit Execution Speed</div>
379
+ <div style="color: #38bdf8; font-size: 22px; font-weight: 700; margin-top: 4px;">55 seconds</div>
380
+ </div>
381
+ </div>
382
+
383
+ <table style="width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; color: #cbd5e1;">
384
+ <thead>
385
+ <tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.15); color: #f1f5f9;">
386
+ <th style="padding: 10px;">Adversarial Variation Kind</th>
387
+ <th style="padding: 10px;">Planted</th>
388
+ <th style="padding: 10px;">Detected</th>
389
+ <th style="padding: 10px;">Missed</th>
390
+ <th style="padding: 10px;">Detection Recall</th>
391
+ </tr>
392
+ </thead>
393
+ <tbody>
394
+ <tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.05);"><td style="padding: 10px;">Exact Duplicate</td><td style="padding: 10px;">10</td><td style="padding: 10px;">10</td><td style="padding: 10px;">0</td><td style="padding: 10px; color: #10b981; font-weight: 700;">100%</td></tr>
395
+ <tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.05);"><td style="padding: 10px;">Resampled 11 kHz</td><td style="padding: 10px;">10</td><td style="padding: 10px;">10</td><td style="padding: 10px;">0</td><td style="padding: 10px; color: #10b981; font-weight: 700;">100%</td></tr>
396
+ <tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.05);"><td style="padding: 10px;">Quieter (-12 dB)</td><td style="padding: 10px;">10</td><td style="padding: 10px;">10</td><td style="padding: 10px;">0</td><td style="padding: 10px; color: #10b981; font-weight: 700;">100%</td></tr>
397
+ <tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.05);"><td style="padding: 10px;">Trimmed 20%</td><td style="padding: 10px;">10</td><td style="padding: 10px;">10</td><td style="padding: 10px;">0</td><td style="padding: 10px; color: #10b981; font-weight: 700;">100%</td></tr>
398
+ <tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.05);"><td style="padding: 10px;">Noisy (~20dB SNR)</td><td style="padding: 10px;">10</td><td style="padding: 10px;">10</td><td style="padding: 10px;">0</td><td style="padding: 10px; color: #10b981; font-weight: 700;">100%</td></tr>
399
+ <tr><td style="padding: 10px;">3-Second Excerpt</td><td style="padding: 10px;">6</td><td style="padding: 10px;">6</td><td style="padding: 10px;">0</td><td style="padding: 10px; color: #10b981; font-weight: 700;">100%</td></tr>
400
+ </tbody>
401
+ </table>
402
+ </div>
403
  """
404
  )
405
 
406
+ gr.HTML(
407
  """
408
+ <div style="margin-top: 30px; padding: 20px; text-align: center; color: #64748b; font-size: 13px; border-top: 1px solid rgba(255, 255, 255, 0.08);">
409
+ ⚑ <strong>SplitSafe v0.1.0a1</strong> &bull; Open-source under MIT License &bull; Built by Boobalan Arjunan
410
+ </div>
411
  """
412
  )
413
 
414
  if __name__ == "__main__":
415
+ demo.launch(css=custom_css)