Spaces:
Runtime error
Runtime error
sanchit-gandhi
commited on
Commit
·
5af76a2
1
Parent(s):
e6468c9
Update app.py
Browse files
app.py
CHANGED
@@ -6,20 +6,17 @@ checkpoint = "openai/whisper-small"
|
|
6 |
pipe = pipeline(model=checkpoint)
|
7 |
|
8 |
|
9 |
-
def transcribe(
|
10 |
warn_output = ""
|
11 |
-
if (
|
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 =
|
15 |
|
16 |
-
elif (
|
17 |
return "ERROR: You have to either use the microphone or upload an audio file"
|
18 |
|
19 |
-
|
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 |
|