Update app.py
Browse files
app.py
CHANGED
|
@@ -47,6 +47,7 @@ def predict(microphone,file_upload):
|
|
| 47 |
|
| 48 |
max_length = 100000
|
| 49 |
warn_output = " "
|
|
|
|
| 50 |
if (microphone is not None) and (file_upload is not None):
|
| 51 |
warn_output = (
|
| 52 |
"WARNING: You've uploaded an audio file and used the microphone. "
|
|
@@ -55,7 +56,8 @@ def predict(microphone,file_upload):
|
|
| 55 |
|
| 56 |
elif (microphone is None) and (file_upload is None):
|
| 57 |
return "ERROR: You have to either use the microphone or upload an audio file"
|
| 58 |
-
|
|
|
|
| 59 |
|
| 60 |
model.eval()
|
| 61 |
with torch.no_grad():
|
|
@@ -81,8 +83,8 @@ def predict(microphone,file_upload):
|
|
| 81 |
gr.Interface(
|
| 82 |
fn=predict,
|
| 83 |
inputs=[
|
| 84 |
-
gr.inputs.Audio(source="microphone", type="
|
| 85 |
-
gr.inputs.Audio(source="upload", type="
|
| 86 |
],
|
| 87 |
outputs="text",
|
| 88 |
title=title,
|
|
|
|
| 47 |
|
| 48 |
max_length = 100000
|
| 49 |
warn_output = " "
|
| 50 |
+
ans = " "
|
| 51 |
if (microphone is not None) and (file_upload is not None):
|
| 52 |
warn_output = (
|
| 53 |
"WARNING: You've uploaded an audio file and used the microphone. "
|
|
|
|
| 56 |
|
| 57 |
elif (microphone is None) and (file_upload is None):
|
| 58 |
return "ERROR: You have to either use the microphone or upload an audio file"
|
| 59 |
+
if(microphone is not None) file_path = microphone
|
| 60 |
+
if(file_upload is not None) file_path = file_upload
|
| 61 |
|
| 62 |
model.eval()
|
| 63 |
with torch.no_grad():
|
|
|
|
| 83 |
gr.Interface(
|
| 84 |
fn=predict,
|
| 85 |
inputs=[
|
| 86 |
+
gr.inputs.Audio(source="microphone", type="file", optional=True),
|
| 87 |
+
gr.inputs.Audio(source="upload", type="file", optional=True),
|
| 88 |
],
|
| 89 |
outputs="text",
|
| 90 |
title=title,
|