sanchit-gandhi HF staff commited on
Commit
5af76a2
1 Parent(s): e6468c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -6,20 +6,17 @@ checkpoint = "openai/whisper-small"
6
  pipe = pipeline(model=checkpoint)
7
 
8
 
9
- def transcribe(Microphone, File_Upload):
10
  warn_output = ""
11
- if (Microphone is not None) and (File_Upload is not None):
12
  warn_output = "WARNING: You've uploaded an audio file and used the microphone. " \
13
  "The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
14
- file = Microphone
15
 
16
- elif (Microphone is None) and (File_Upload is None):
17
  return "ERROR: You have to either use the microphone or upload an audio file"
18
 
19
- elif Microphone is not None:
20
- file = Microphone
21
- else:
22
- file = File_Upload
23
 
24
  text = pipe(file)["text"]
25
 
 
6
  pipe = pipeline(model=checkpoint)
7
 
8
 
9
+ def transcribe(microphone, file_upload):
10
  warn_output = ""
11
+ if (microphone is not None) and (file_upload is not None):
12
  warn_output = "WARNING: You've uploaded an audio file and used the microphone. " \
13
  "The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
14
+ file = microphone
15
 
16
+ elif (microphone is None) and (file_upload is None):
17
  return "ERROR: You have to either use the microphone or upload an audio file"
18
 
19
+ file = microphone if microphone is not None else file_upload
 
 
 
20
 
21
  text = pipe(file)["text"]
22