smajumdar commited on
Commit
84c1c49
1 Parent(s): d98f9ce

Signed-off-by: smajumdar <[email protected]>

Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -90,7 +90,7 @@ model_dict = {}
90
  for model_name in SUPPORTED_MODEL_NAMES:
91
  try:
92
  iface = gr.Interface.load(f'models/{model_name}')
93
- model_dict[model_name] = model_dict
94
  except:
95
  pass
96
 
@@ -369,8 +369,21 @@ def infer_audio(model_name: str, audio_file: str) -> str:
369
 
370
  if model is not None:
371
  # Use HF API for transcription
372
- transcriptions = model(audio_file)
373
- return transcriptions
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  else:
375
  error = (
376
  f"Error:- Could not find model {model_name} in list of available models : "
@@ -422,8 +435,6 @@ def transcribe(microphone, audio_file, model_name):
422
  time_diff = end - start
423
 
424
  except Exception as e:
425
- print(traceback.print_exc())
426
-
427
  transcriptions = ""
428
  warn_output = warn_output
429
 
 
90
  for model_name in SUPPORTED_MODEL_NAMES:
91
  try:
92
  iface = gr.Interface.load(f'models/{model_name}')
93
+ model_dict[model_name] = iface
94
  except:
95
  pass
96
 
 
369
 
370
  if model is not None:
371
  # Use HF API for transcription
372
+ try:
373
+ transcriptions = model(audio_file)
374
+ return transcriptions
375
+ except Exception as e:
376
+ transcriptions = ""
377
+ error = ""
378
+
379
+ error += (
380
+ f"The model `{model_name}` is currently loading and cannot be used "
381
+ f"for transcription.<br>"
382
+ f"Please try another model or wait a few minutes."
383
+ )
384
+
385
+ return error
386
+
387
  else:
388
  error = (
389
  f"Error:- Could not find model {model_name} in list of available models : "
 
435
  time_diff = end - start
436
 
437
  except Exception as e:
 
 
438
  transcriptions = ""
439
  warn_output = warn_output
440