deepakkumar07 commited on
Commit
5f21810
·
verified ·
1 Parent(s): 0ce1e34

check to see if audio is available

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -7,15 +7,18 @@ pipe = pipeline(task="automatic-speech-recognition",
7
  model="openai/whisper-small",
8
  device="cuda" if torch.cuda.is_available() else "cpu")
9
 
 
10
  def initialize_pipeline(model_name):
11
  global pipe
12
  pipe = pipeline(task="automatic-speech-recognition",
13
- model=model_name,
14
- device="cuda" if torch.cuda.is_available() else "cpu")
15
  return model_name
16
 
17
 
18
  def transcribe(audio):
 
 
19
  text = pipe(audio)["text"]
20
  return text
21
 
 
7
  model="openai/whisper-small",
8
  device="cuda" if torch.cuda.is_available() else "cpu")
9
 
10
+
11
  def initialize_pipeline(model_name):
12
  global pipe
13
  pipe = pipeline(task="automatic-speech-recognition",
14
+ model=model_name,
15
+ device="cuda" if torch.cuda.is_available() else "cpu")
16
  return model_name
17
 
18
 
19
  def transcribe(audio):
20
+ if audio is None:
21
+ return "No audio input received. Please try again."
22
  text = pipe(audio)["text"]
23
  return text
24