Spaces:
Runtime error
Runtime error
liuyang
commited on
Commit
Β·
e79159f
1
Parent(s):
e3d9c9e
Add audio diarization task to Gradio interface: Introduced a new button and function for audio diarization, allowing users to process audio with speaker separation. Updated existing button labels for clarity.
Browse files
app.py
CHANGED
|
@@ -1316,8 +1316,20 @@ def format_segments_for_display(result):
|
|
| 1316 |
|
| 1317 |
return output
|
| 1318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1319 |
@spaces.GPU
|
| 1320 |
-
def
|
| 1321 |
"""Gradio interface function"""
|
| 1322 |
|
| 1323 |
result = transcriber.process_audio_transcribe(
|
|
@@ -1421,7 +1433,8 @@ with demo:
|
|
| 1421 |
value=True
|
| 1422 |
)
|
| 1423 |
|
| 1424 |
-
process_btn = gr.Button("π Transcribe
|
|
|
|
| 1425 |
|
| 1426 |
with gr.Column():
|
| 1427 |
output_text = gr.Markdown(
|
|
@@ -1443,7 +1456,7 @@ with demo:
|
|
| 1443 |
|
| 1444 |
# Event handlers
|
| 1445 |
process_btn.click(
|
| 1446 |
-
fn=
|
| 1447 |
inputs=[
|
| 1448 |
task_json_input,
|
| 1449 |
num_speakers,
|
|
@@ -1457,6 +1470,15 @@ with demo:
|
|
| 1457 |
],
|
| 1458 |
outputs=[output_text, output_json]
|
| 1459 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1460 |
|
| 1461 |
# Examples
|
| 1462 |
gr.Markdown("### π Usage Tips:")
|
|
|
|
| 1316 |
|
| 1317 |
return output
|
| 1318 |
|
| 1319 |
+
|
| 1320 |
+
@spaces.GPU
|
| 1321 |
+
def audio_diarization_task(task_json, num_speakers):
|
| 1322 |
+
"""Gradio interface function"""
|
| 1323 |
+
|
| 1324 |
+
result = transcriber.process_audio_diarization(
|
| 1325 |
+
task_json=task_json,
|
| 1326 |
+
num_speakers=num_speakers if num_speakers > 0 else None,
|
| 1327 |
+
)
|
| 1328 |
+
#formatted_output = format_segments_for_display(result)
|
| 1329 |
+
return "OK", result
|
| 1330 |
+
|
| 1331 |
@spaces.GPU
|
| 1332 |
+
def audio_transcribe_task(task_json, num_speakers, language, translate, prompt, group_segments, use_diarization, batch_size, model_name):
|
| 1333 |
"""Gradio interface function"""
|
| 1334 |
|
| 1335 |
result = transcriber.process_audio_transcribe(
|
|
|
|
| 1433 |
value=True
|
| 1434 |
)
|
| 1435 |
|
| 1436 |
+
process_btn = gr.Button("π Audio Transcribe Task", variant="primary")
|
| 1437 |
+
process_btn1 = gr.Button("π Audio Diarization Task", variant="primary")
|
| 1438 |
|
| 1439 |
with gr.Column():
|
| 1440 |
output_text = gr.Markdown(
|
|
|
|
| 1456 |
|
| 1457 |
# Event handlers
|
| 1458 |
process_btn.click(
|
| 1459 |
+
fn=audio_transcribe_task,
|
| 1460 |
inputs=[
|
| 1461 |
task_json_input,
|
| 1462 |
num_speakers,
|
|
|
|
| 1470 |
],
|
| 1471 |
outputs=[output_text, output_json]
|
| 1472 |
)
|
| 1473 |
+
|
| 1474 |
+
process_btn1.click(
|
| 1475 |
+
fn=audio_diarization_task,
|
| 1476 |
+
inputs=[
|
| 1477 |
+
task_json_input,
|
| 1478 |
+
num_speakers
|
| 1479 |
+
],
|
| 1480 |
+
outputs=[output_text, output_json]
|
| 1481 |
+
)
|
| 1482 |
|
| 1483 |
# Examples
|
| 1484 |
gr.Markdown("### π Usage Tips:")
|