Spaces:
Sleeping
Sleeping
ftshijt
commited on
Commit
·
67347ea
1
Parent(s):
73d9817
update app for file scp setup
Browse files
app.py
CHANGED
@@ -277,8 +277,8 @@ def evaluate_audio(gt_file, pred_file, metric_config, include_timestamps=False):
|
|
277 |
if not versa_installed:
|
278 |
return None, "VERSA is not installed. Evaluation cannot be performed."
|
279 |
|
280 |
-
if
|
281 |
-
return None, "Please upload
|
282 |
|
283 |
# Determine the metric config path
|
284 |
if metric_config.startswith("custom/"):
|
@@ -291,13 +291,26 @@ def evaluate_audio(gt_file, pred_file, metric_config, include_timestamps=False):
|
|
291 |
# Create temp directory for results
|
292 |
with tempfile.TemporaryDirectory() as temp_dir:
|
293 |
output_file = os.path.join(temp_dir, "result.json")
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
# Build command
|
296 |
cmd = [
|
297 |
sys.executable, VERSA_BIN,
|
298 |
"--score_config", metric_config_path,
|
299 |
-
"--gt",
|
300 |
-
"--pred",
|
301 |
"--output_file", output_file,
|
302 |
"--use_gpu", "true",
|
303 |
]
|
@@ -378,8 +391,8 @@ def create_gradio_demo():
|
|
378 |
with gr.TabItem("Standard Evaluation"):
|
379 |
with gr.Row():
|
380 |
with gr.Column():
|
381 |
-
gt_audio = gr.Audio(label="Ground Truth Audio", type="filepath", sources=["upload", "microphone"])
|
382 |
pred_audio = gr.Audio(label="Prediction Audio", type="filepath", sources=["upload", "microphone"])
|
|
|
383 |
|
384 |
metric_dropdown = gr.Dropdown(
|
385 |
choices=available_metrics,
|
|
|
277 |
if not versa_installed:
|
278 |
return None, "VERSA is not installed. Evaluation cannot be performed."
|
279 |
|
280 |
+
if pred_file is None:
|
281 |
+
return None, "Please upload the audio file to be evaluated."
|
282 |
|
283 |
# Determine the metric config path
|
284 |
if metric_config.startswith("custom/"):
|
|
|
291 |
# Create temp directory for results
|
292 |
with tempfile.TemporaryDirectory() as temp_dir:
|
293 |
output_file = os.path.join(temp_dir, "result.json")
|
294 |
+
|
295 |
+
# Create SCP file
|
296 |
+
pred_scp_path = os.path.join(temp_dir, "pred.scp")
|
297 |
+
with open(pred_scp_path, "w") as pred_scp:
|
298 |
+
pred_scp.write("test {}\n".format(pred_file))
|
299 |
+
|
300 |
+
# For case without reference audio
|
301 |
+
if gt_file is not None:
|
302 |
+
gt_scp_path = os.path.join(temp_dir, "gt.scp")
|
303 |
+
with open(gt_scp_path, "w") as gt_scp:
|
304 |
+
gt_scp.write("test {}\n".format(gt_file))
|
305 |
+
else:
|
306 |
+
gt_scp_path = "None"
|
307 |
+
|
308 |
# Build command
|
309 |
cmd = [
|
310 |
sys.executable, VERSA_BIN,
|
311 |
"--score_config", metric_config_path,
|
312 |
+
"--gt", gt_scp_path,
|
313 |
+
"--pred", pred_scp_path,
|
314 |
"--output_file", output_file,
|
315 |
"--use_gpu", "true",
|
316 |
]
|
|
|
391 |
with gr.TabItem("Standard Evaluation"):
|
392 |
with gr.Row():
|
393 |
with gr.Column():
|
|
|
394 |
pred_audio = gr.Audio(label="Prediction Audio", type="filepath", sources=["upload", "microphone"])
|
395 |
+
gt_audio = gr.Audio(label="Ground Truth Audio", type="filepath", sources=["upload", "microphone"])
|
396 |
|
397 |
metric_dropdown = gr.Dropdown(
|
398 |
choices=available_metrics,
|