Added choice for Model Size
Browse files
app.py
CHANGED
@@ -4,6 +4,13 @@ import gradio as gr
|
|
4 |
import whisper
|
5 |
|
6 |
model = whisper.load_model("small")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
def inference(audio):
|
@@ -131,13 +138,17 @@ with block:
|
|
131 |
<p style="margin-bottom: 10px; font-size: 94%">
|
132 |
Whisper is a general-purpose speech recognition model. It has been trained on a large dataset of diverse audio and is also a multi-task model that can perform multilingual speech recognition as well as speech translation and language identification. </p>
|
133 |
<p>This is a fork by JTHTEO.</p>
|
134 |
-
<p>
|
135 |
</p>
|
136 |
</div>
|
137 |
"""
|
138 |
)
|
139 |
with gr.Group():
|
140 |
with gr.Box():
|
|
|
|
|
|
|
|
|
141 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
142 |
audio = gr.Audio(
|
143 |
label="Input Audio",
|
@@ -147,10 +158,13 @@ with block:
|
|
147 |
)
|
148 |
btn = gr.Button("Transcribe")
|
149 |
text = gr.Textbox(show_label=False)
|
150 |
-
|
151 |
-
|
|
|
152 |
btn.click(inference, inputs=[audio], outputs=[text])
|
153 |
|
|
|
|
|
154 |
gr.HTML('''
|
155 |
<div class="footer">
|
156 |
<p>Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a> - Gradio Demo by 🤗 Hugging Face, this is a fork by JTHTEO
|
|
|
4 |
import whisper
|
5 |
|
6 |
model = whisper.load_model("small")
|
7 |
+
current_size = 'small'
|
8 |
+
|
9 |
+
def change_model(size):
|
10 |
+
if size == current_size:
|
11 |
+
return
|
12 |
+
model = whisper.load_model(size)
|
13 |
+
current_size = size
|
14 |
|
15 |
|
16 |
def inference(audio):
|
|
|
138 |
<p style="margin-bottom: 10px; font-size: 94%">
|
139 |
Whisper is a general-purpose speech recognition model. It has been trained on a large dataset of diverse audio and is also a multi-task model that can perform multilingual speech recognition as well as speech translation and language identification. </p>
|
140 |
<p>This is a fork by JTHTEO.</p>
|
141 |
+
<p>The different sized Whisper models can be found in this (<a href="https://github.com/openai/whisper/blob/main/model-card.md">Model Card</a>.) </p>
|
142 |
</p>
|
143 |
</div>
|
144 |
"""
|
145 |
)
|
146 |
with gr.Group():
|
147 |
with gr.Box():
|
148 |
+
wmodel = gr.Radio(
|
149 |
+
choices=["tiny", "base", "small", "medium", "large"],
|
150 |
+
label="Model used",
|
151 |
+
value="small")
|
152 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
153 |
audio = gr.Audio(
|
154 |
label="Input Audio",
|
|
|
158 |
)
|
159 |
btn = gr.Button("Transcribe")
|
160 |
text = gr.Textbox(show_label=False)
|
161 |
+
|
162 |
+
##events###
|
163 |
+
wmodel.change(change_model, inputs=[wmodel], outputs=[])
|
164 |
btn.click(inference, inputs=[audio], outputs=[text])
|
165 |
|
166 |
+
##footer###
|
167 |
+
|
168 |
gr.HTML('''
|
169 |
<div class="footer">
|
170 |
<p>Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a> - Gradio Demo by 🤗 Hugging Face, this is a fork by JTHTEO
|