anzorq commited on
Commit
03660fe
1 Parent(s): 401c5ee

+ choosing model size

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -11,9 +11,11 @@ AUTO_DETECT_LANG = "Auto Detect"
11
  def transcribe(audio, state={}, model_size='base', delay=1.2, lang=None, translate=False):
12
  time.sleep(delay - 1)
13
 
 
 
14
  if model_size != current_size:
15
- model = whisper.load_model(model_size)
16
  current_size = model_size
 
17
 
18
  transcription = model.transcribe(
19
  audio,
@@ -35,11 +37,11 @@ def transcribe(audio, state={}, model_size='base', delay=1.2, lang=None, transla
35
 
36
 
37
  title = "OpenAI's Whisper Real-time Demo"
38
- description = "A simple demo of OpenAI's [**Whisper**](https://github.com/openai/whisper) speech recognition model."
39
 
40
  model_size = gr.Dropdown(label="Model size", choices=['base', 'tiny', 'small', 'medium', 'large'], value='base')
41
 
42
- delay_slider = gr.inputs.Slider(minimum=1, maximum=5, default=1.2, label="Rate of transcription, s")
43
 
44
  available_languages = sorted(tokenizer.TO_LANGUAGE_CODE.keys())
45
  available_languages = [lang.capitalize() for lang in available_languages]
 
11
  def transcribe(audio, state={}, model_size='base', delay=1.2, lang=None, translate=False):
12
  time.sleep(delay - 1)
13
 
14
+ global current_size
15
+ global model
16
  if model_size != current_size:
 
17
  current_size = model_size
18
+ model = whisper.load_model(current_size)
19
 
20
  transcription = model.transcribe(
21
  audio,
 
37
 
38
 
39
  title = "OpenAI's Whisper Real-time Demo"
40
+ description = "A simple demo of OpenAI's [**Whisper**](https://github.com/openai/whisper) speech recognition model. This demo runs on a CPU. For faster inference choose 'tiny' model size and set the language explicitly."
41
 
42
  model_size = gr.Dropdown(label="Model size", choices=['base', 'tiny', 'small', 'medium', 'large'], value='base')
43
 
44
+ delay_slider = gr.inputs.Slider(minimum=1, maximum=5, default=1.2, label="Rate of transcription")
45
 
46
  available_languages = sorted(tokenizer.TO_LANGUAGE_CODE.keys())
47
  available_languages = [lang.capitalize() for lang in available_languages]