BassWow commited on
Commit
e67af8d
1 Parent(s): b568657
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -2,9 +2,10 @@ import gradio as gr
2
  import whisper
3
  from langcodes import *
4
 
5
- def speech_to_text(tmp_filename, model_size):
6
  model = whisper.load_model(model_size)
7
- result = model.transcribe(tmp_filename)
 
8
  return f'Detected language: {Language.make(language=result["language"]).display_name()}\n\n You said: {result["text"]}'
9
 
10
 
@@ -20,6 +21,7 @@ gr.Interface(
20
  fn=speech_to_text,
21
  inputs=[
22
  gr.Audio(label="Record your voice on your mic",source="microphone", type="filepath"),
 
23
  gr.Dropdown(label="Select model size",value="base",choices=["tiny", "base", "small", "medium", "large"])],
24
  outputs="text").launch()
25
 
 
2
  import whisper
3
  from langcodes import *
4
 
5
+ def speech_to_text(tmp_filename, uploaded, model_size):
6
  model = whisper.load_model(model_size)
7
+ source = uploaded if uploaded is not None else tmp_filename
8
+ result = model.transcribe(source)
9
  return f'Detected language: {Language.make(language=result["language"]).display_name()}\n\n You said: {result["text"]}'
10
 
11
 
 
21
  fn=speech_to_text,
22
  inputs=[
23
  gr.Audio(label="Record your voice on your mic",source="microphone", type="filepath"),
24
+ gr.Audio(source="upload", type="filepath", label="Upload Audio"),
25
  gr.Dropdown(label="Select model size",value="base",choices=["tiny", "base", "small", "medium", "large"])],
26
  outputs="text").launch()
27