Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1102,12 +1102,24 @@ with gr.Blocks(theme=THEME, title="TranscribeAI", css=CUSTOM_CSS, head=UPLOAD_PR
|
|
| 1102 |
docx_file = gr.File(label="DOCX — Dokumen Word berwarna")
|
| 1103 |
|
| 1104 |
# ---- Connect ----
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1105 |
btn_start.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1106 |
fn=transcribe_full,
|
| 1107 |
inputs=[audio_input, language_choice, speaker_count,
|
| 1108 |
enable_diarization, enable_vad],
|
| 1109 |
outputs=[summary_output, transcript_output, srt_file, txt_file, docx_file],
|
| 1110 |
-
js="() => {
|
| 1111 |
).then(
|
| 1112 |
fn=lambda: None,
|
| 1113 |
inputs=None,
|
|
|
|
| 1102 |
docx_file = gr.File(label="DOCX — Dokumen Word berwarna")
|
| 1103 |
|
| 1104 |
# ---- Connect ----
|
| 1105 |
+
# Step 1: Validate audio exists (quick, no GPU).
|
| 1106 |
+
# If error → chain stops → timer never starts.
|
| 1107 |
+
# Step 2: Start timer (JS) + run transcription (GPU).
|
| 1108 |
+
# Step 3: Stop timer on success (JS).
|
| 1109 |
+
def validate_audio(audio_file):
|
| 1110 |
+
if audio_file is None:
|
| 1111 |
+
raise gr.Error("Upload file audio terlebih dahulu!")
|
| 1112 |
+
|
| 1113 |
btn_start.click(
|
| 1114 |
+
fn=validate_audio,
|
| 1115 |
+
inputs=[audio_input],
|
| 1116 |
+
outputs=None,
|
| 1117 |
+
).then(
|
| 1118 |
fn=transcribe_full,
|
| 1119 |
inputs=[audio_input, language_choice, speaker_count,
|
| 1120 |
enable_diarization, enable_vad],
|
| 1121 |
outputs=[summary_output, transcript_output, srt_file, txt_file, docx_file],
|
| 1122 |
+
js="() => { window.startTranscribeTimer(); }",
|
| 1123 |
).then(
|
| 1124 |
fn=lambda: None,
|
| 1125 |
inputs=None,
|