R-TA commited on
Commit
e52719e
·
verified ·
1 Parent(s): 60134fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -1,15 +1,35 @@
1
  import whisper
2
  import gradio as gr
3
 
 
4
  model = whisper.load_model("small")
5
 
6
- def transcribe(audio):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  result = model.transcribe(audio)
8
  return result["text"]
9
 
10
  gr.Interface(
11
  fn=transcribe,
12
- inputs=gr.Audio(type="filepath"),
 
 
 
13
  outputs="text",
14
- title="Whisper‑Small STT"
 
15
  ).launch()
 
1
  import whisper
2
  import gradio as gr
3
 
4
+ # Preload default model
5
  model = whisper.load_model("small")
6
 
7
+ # Cache models to avoid re-downloading
8
+ models = {
9
+ "tiny": None,
10
+ "base": None,
11
+ "small": model,
12
+ "medium": None,
13
+ "large": None
14
+ }
15
+
16
+ def load_model(selected_model):
17
+ if models[selected_model] is None:
18
+ models[selected_model] = whisper.load_model(selected_model)
19
+ return models[selected_model]
20
+
21
+ def transcribe(audio, model_name):
22
+ model = load_model(model_name)
23
  result = model.transcribe(audio)
24
  return result["text"]
25
 
26
  gr.Interface(
27
  fn=transcribe,
28
+ inputs=[
29
+ gr.Audio(type="filepath", label="Upload Audio"),
30
+ gr.Dropdown(["tiny", "base", "small", "medium", "large"], value="small", label="Choose Whisper Model")
31
+ ],
32
  outputs="text",
33
+ title="Whisper Multilingual STT (All Models)",
34
+ description="Upload an audio file and choose which Whisper model to use for transcription. Supports multiple languages including Korean, Urdu, Arabic, etc."
35
  ).launch()