eustlb HF Staff commited on
Commit
ae8f8a8
·
1 Parent(s): f9d3bcf

add whisper tiny

Browse files
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -119,18 +119,6 @@ def transcribe(inputs):
119
  distil_text = distil_pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
120
  yield distil_text, distil_runtime, None, None, None, None
121
 
122
- def _forward_time(*args, **kwargs):
123
- global runtime
124
- start_time = time.time()
125
- result = pipe_forward(*args, **kwargs)
126
- runtime = time.time() - start_time
127
- runtime = round(runtime, 2)
128
- return result
129
-
130
- pipe._forward = _forward_time
131
- text = pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
132
- yield distil_text, distil_runtime, text, runtime, None, None
133
-
134
  def _forward_tiny_time(*args, **kwargs):
135
  global tiny_runtime
136
  start_time = time.time()
@@ -141,8 +129,19 @@ def transcribe(inputs):
141
 
142
  tiny_pipe._forward = _forward_tiny_time
143
  tiny_text = tiny_pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
 
144
 
145
- yield distil_text, distil_runtime, text, runtime, tiny_text, tiny_runtime
 
 
 
 
 
 
 
 
 
 
146
 
147
  if __name__ == "__main__":
148
  with gr.Blocks() as demo:
@@ -179,23 +178,23 @@ if __name__ == "__main__":
179
  button = gr.Button("Transcribe")
180
  with gr.Row():
181
  distil_runtime = gr.components.Textbox(label="distil-large-v3 Transcription Time (s)")
182
- runtime = gr.components.Textbox(label="whisper-largel-v3 Transcription Time (s)")
183
  tiny_runtime = gr.components.Textbox(label="whisper-tiny Transcription Time (s)")
 
184
 
185
  with gr.Row():
186
  distil_transcription = gr.components.Textbox(label="distil-large-v3 Transcription", show_copy_button=True)
187
- transcription = gr.components.Textbox(label="whisper-largel-v3 Transcription", show_copy_button=True)
188
  tiny_transcription = gr.components.Textbox(label="whisper-tiny Transcription", show_copy_button=True)
 
189
  button.click(
190
  fn=transcribe,
191
  inputs=audio,
192
- outputs=[distil_transcription, distil_runtime, transcription, runtime, tiny_transcription, tiny_runtime],
193
  )
194
  gr.Markdown("## Examples")
195
  gr.Examples(
196
  [["./assets/example_1.wav"], ["./assets/example_2.wav"]],
197
  audio,
198
- outputs=[distil_transcription, distil_runtime, transcription, runtime, tiny_transcription, tiny_runtime],
199
  fn=transcribe,
200
  cache_examples=False,
201
  )
 
119
  distil_text = distil_pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
120
  yield distil_text, distil_runtime, None, None, None, None
121
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  def _forward_tiny_time(*args, **kwargs):
123
  global tiny_runtime
124
  start_time = time.time()
 
129
 
130
  tiny_pipe._forward = _forward_tiny_time
131
  tiny_text = tiny_pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
132
+ yield distil_text, distil_runtime, tiny_text, tiny_runtime, None, None
133
 
134
+ def _forward_time(*args, **kwargs):
135
+ global runtime
136
+ start_time = time.time()
137
+ result = pipe_forward(*args, **kwargs)
138
+ runtime = time.time() - start_time
139
+ runtime = round(runtime, 2)
140
+ return result
141
+
142
+ pipe._forward = _forward_time
143
+ text = pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
144
+ yield distil_text, distil_runtime, tiny_text, tiny_runtime, text, runtime
145
 
146
  if __name__ == "__main__":
147
  with gr.Blocks() as demo:
 
178
  button = gr.Button("Transcribe")
179
  with gr.Row():
180
  distil_runtime = gr.components.Textbox(label="distil-large-v3 Transcription Time (s)")
 
181
  tiny_runtime = gr.components.Textbox(label="whisper-tiny Transcription Time (s)")
182
+ runtime = gr.components.Textbox(label="whisper-largel-v3 Transcription Time (s)")
183
 
184
  with gr.Row():
185
  distil_transcription = gr.components.Textbox(label="distil-large-v3 Transcription", show_copy_button=True)
 
186
  tiny_transcription = gr.components.Textbox(label="whisper-tiny Transcription", show_copy_button=True)
187
+ transcription = gr.components.Textbox(label="whisper-largel-v3 Transcription", show_copy_button=True)
188
  button.click(
189
  fn=transcribe,
190
  inputs=audio,
191
+ outputs=[distil_transcription, distil_runtime, tiny_transcription, tiny_runtime, transcription, runtime],
192
  )
193
  gr.Markdown("## Examples")
194
  gr.Examples(
195
  [["./assets/example_1.wav"], ["./assets/example_2.wav"]],
196
  audio,
197
+ outputs=[distil_transcription, distil_runtime, tiny_transcription, tiny_runtime, transcription, runtime],
198
  fn=transcribe,
199
  cache_examples=False,
200
  )