EladSpamson commited on
Commit
4dc8e9d
·
verified ·
1 Parent(s): b08165c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -15
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, # keep under total token limit
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
- with gr.Blocks() as demo:
90
- gr.Markdown("## Hebrew Whisper (Truncate to 30s, No Progress Bar)")
91
-
92
- audio_input = gr.Audio(type="filepath", label="Upload Audio (Truncate to 30s)")
93
- output_text = gr.Textbox(label="Partial Transcription")
94
-
95
- start_btn = gr.Button("Start Transcription")
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()