Politrees commited on
Commit
24cbfc6
·
verified ·
1 Parent(s): 7d3a1b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -15
app.py CHANGED
@@ -182,21 +182,25 @@ def rename_stems(audio, vocals_stem, instrumental_stem, other_stem, drums_stem,
182
  return stems
183
 
184
  def leaderboard(list_filter, list_limit):
185
- result = subprocess.run(
186
- ["PolUVR", "-l", f"--list_filter={list_filter}", f"--list_limit={list_limit}"],
187
- capture_output=True,
188
- text=True,
189
- shell=True,
190
- )
191
- if result.returncode != 0:
192
- return f"Error: {result.stderr}"
193
-
194
- return "<table border='1'>" + "".join(
195
- f"<tr style='{'font-weight: bold; font-size: 1.2em;' if i == 0 else ''}'>" +
196
- "".join(f"<td>{cell}</td>" for cell in re.split(r"\s{2,}", line.strip())) +
197
- "</tr>"
198
- for i, line in enumerate(re.findall(r"^(?!-+)(.+)$", result.stdout.strip(), re.MULTILINE))
199
- ) + "</table>"
 
 
 
 
200
 
201
  def roformer_separator(audio, model_key, seg_size, override_seg_size, overlap, pitch_shift, model_dir, out_dir, out_format, norm_thresh, amp_thresh, batch_size, vocals_stem, instrumental_stem, other_stem, drums_stem, bass_stem, guitar_stem, piano_stem, progress=gr.Progress(track_tqdm=True)):
202
  """Separate audio using Roformer model."""
 
182
  return stems
183
 
184
  def leaderboard(list_filter, list_limit):
185
+ try:
186
+ result = subprocess.run(
187
+ ["PolUVR", "-l", f"--list_filter={list_filter}", f"--list_limit={list_limit}"],
188
+ capture_output=True,
189
+ text=True,
190
+ shell=True,
191
+ )
192
+ if result.returncode != 0:
193
+ return f"Error: {result.stderr}"
194
+
195
+ return "<table border='1'>" + "".join(
196
+ f"<tr style='{'font-weight: bold; font-size: 1.2em;' if i == 0 else ''}'>" +
197
+ "".join(f"<td>{cell}</td>" for cell in re.split(r"\s{2,}", line.strip())) +
198
+ "</tr>"
199
+ for i, line in enumerate(re.findall(r"^(?!-+)(.+)$", result.stdout.strip(), re.MULTILINE))
200
+ ) + "</table>"
201
+
202
+ except Exception as e:
203
+ return f"Error: {e}"
204
 
205
  def roformer_separator(audio, model_key, seg_size, override_seg_size, overlap, pitch_shift, model_dir, out_dir, out_format, norm_thresh, amp_thresh, batch_size, vocals_stem, instrumental_stem, other_stem, drums_stem, bass_stem, guitar_stem, piano_stem, progress=gr.Progress(track_tqdm=True)):
206
  """Separate audio using Roformer model."""