Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -74,7 +74,7 @@ def transcribe_30_seconds(audio_file):
|
|
74 |
predicted_ids = model.generate(
|
75 |
input_features,
|
76 |
attention_mask=attention_mask,
|
77 |
-
max_new_tokens=444,
|
78 |
do_sample=False,
|
79 |
forced_decoder_ids=forced_decoder_ids
|
80 |
)
|
@@ -82,21 +82,15 @@ def transcribe_30_seconds(audio_file):
|
|
82 |
text_chunk = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
83 |
partial_text += text_chunk + "\n"
|
84 |
|
85 |
-
# Send updated partial text to the UI
|
86 |
yield partial_text
|
87 |
|
88 |
-
# Build Gradio UI
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
stop_btn = gr.Button("Stop Processing", variant="stop")
|
97 |
-
|
98 |
-
# Stream chunk-by-chunk, no progress bar
|
99 |
-
start_btn.click(transcribe_30_seconds, inputs=audio_input, outputs=output_text)
|
100 |
-
stop_btn.click(stop)
|
101 |
|
102 |
demo.launch()
|
|
|
74 |
predicted_ids = model.generate(
|
75 |
input_features,
|
76 |
attention_mask=attention_mask,
|
77 |
+
max_new_tokens=444,
|
78 |
do_sample=False,
|
79 |
forced_decoder_ids=forced_decoder_ids
|
80 |
)
|
|
|
82 |
text_chunk = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
83 |
partial_text += text_chunk + "\n"
|
84 |
|
|
|
85 |
yield partial_text
|
86 |
|
87 |
+
# Build Gradio UI with API support
|
88 |
+
demo = gr.Interface(
|
89 |
+
fn=transcribe_30_seconds,
|
90 |
+
inputs=gr.Audio(type="filepath"),
|
91 |
+
outputs="text",
|
92 |
+
title="Hebrew Whisper API",
|
93 |
+
api_name="transcribe" # Enables API access
|
94 |
+
)
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
demo.launch()
|