Update app.py
Browse files
app.py
CHANGED
|
@@ -484,45 +484,34 @@ def transcribe_multiple(audio_files, model_name, advanced_options, merge_checkbo
|
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
-
#
|
| 488 |
def run_transcription_wrapper(files, model_name, merge, zip_file, zip_password, enable_memory, advanced_options_state):
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
with gr.Column(scale=3):
|
| 516 |
-
logs = gr.Textbox(label="Logs (streaming)", lines=12)
|
| 517 |
-
transcripts_out = gr.Textbox(label="Transcripts (streaming)", lines=12)
|
| 518 |
-
download_file = gr.File(label="Merged .docx (when enabled)")
|
| 519 |
-
progress_num = gr.Number(value=0, label="Progress (%)")
|
| 520 |
-
|
| 521 |
-
submit.click(
|
| 522 |
-
fn=run_transcription_wrapper,
|
| 523 |
-
inputs=[file_input, model_select, merge_checkbox, zip_input, zip_password, memory_checkbox, gr.State({})],
|
| 524 |
-
outputs=[logs, transcripts_out, download_file, progress_num],
|
| 525 |
-
)
|
| 526 |
|
| 527 |
# Launch
|
| 528 |
if __name__ == "__main__":
|
|
|
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
+
# Defensive wrapper to surface exceptions into the Logs textbox
|
| 488 |
def run_transcription_wrapper(files, model_name, merge, zip_file, zip_password, enable_memory, advanced_options_state):
|
| 489 |
+
import traceback, io
|
| 490 |
+
try:
|
| 491 |
+
audio_input = files
|
| 492 |
+
zip_path = None
|
| 493 |
+
if zip_file:
|
| 494 |
+
if isinstance(zip_file, (str, os.PathLike)):
|
| 495 |
+
zip_path = str(zip_file)
|
| 496 |
+
elif hasattr(zip_file, "name"):
|
| 497 |
+
zip_path = zip_file.name
|
| 498 |
+
elif isinstance(zip_file, dict) and zip_file.get("name"):
|
| 499 |
+
zip_path = zip_file["name"]
|
| 500 |
+
adv = {}
|
| 501 |
+
# return the generator directly (transcribe_multiple yields tuples)
|
| 502 |
+
return transcribe_multiple(audio_input, model_name, adv, merge_checkbox=merge, zip_file=zip_path, zip_password=zip_password, enable_memory=enable_memory)
|
| 503 |
+
except Exception as e:
|
| 504 |
+
# If anything raises before generator returned, produce a generator that yields the traceback
|
| 505 |
+
buf = io.StringIO()
|
| 506 |
+
traceback.print_exc(file=buf)
|
| 507 |
+
tb = buf.getvalue()
|
| 508 |
+
logs = f"EXCEPTION in run_transcription_wrapper:\n{tb}"
|
| 509 |
+
transcripts = "ERROR: transcription did not start due to exception."
|
| 510 |
+
# Yield once with logs and final 100% to stop spinner
|
| 511 |
+
def error_gen():
|
| 512 |
+
yield logs, transcripts, None, 100
|
| 513 |
+
return error_gen()
|
| 514 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
|
| 516 |
# Launch
|
| 517 |
if __name__ == "__main__":
|