Spaces:
Sleeping
Sleeping
fixes
Browse files
app.py
CHANGED
|
@@ -13,20 +13,12 @@ pipe = pipeline(
|
|
| 13 |
device=device,
|
| 14 |
)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
def transcribe(microphone, file_upload):
|
| 19 |
warn_output = ""
|
| 20 |
-
if (
|
| 21 |
-
warn_output = (
|
| 22 |
-
"WARNING: You've uploaded an audio file and used the microphone. "
|
| 23 |
-
"The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
elif (microphone is None) and (file_upload is None):
|
| 27 |
return "ERROR: You have to either use the microphone or upload an audio file"
|
| 28 |
|
| 29 |
-
file =
|
| 30 |
|
| 31 |
text = pipe(file)["text"]
|
| 32 |
|
|
@@ -36,11 +28,9 @@ def transcribe(microphone, file_upload):
|
|
| 36 |
iface = gr.Interface(
|
| 37 |
fn=transcribe,
|
| 38 |
inputs=[
|
| 39 |
-
gr.
|
| 40 |
-
gr.inputs.Audio(source="upload", type="filepath", optional=True),
|
| 41 |
],
|
| 42 |
outputs="text",
|
| 43 |
-
layout="horizontal",
|
| 44 |
theme="huggingface",
|
| 45 |
title="Wav2Vec2-Bert demo - transcribe Czech Audio",
|
| 46 |
description=(
|
|
|
|
| 13 |
device=device,
|
| 14 |
)
|
| 15 |
|
| 16 |
+
def transcribe(file_upload):
|
|
|
|
|
|
|
| 17 |
warn_output = ""
|
| 18 |
+
if (file_upload is None):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
return "ERROR: You have to either use the microphone or upload an audio file"
|
| 20 |
|
| 21 |
+
file = file_upload
|
| 22 |
|
| 23 |
text = pipe(file)["text"]
|
| 24 |
|
|
|
|
| 28 |
iface = gr.Interface(
|
| 29 |
fn=transcribe,
|
| 30 |
inputs=[
|
| 31 |
+
gr.File(type="binary", label="Upload Audio File"), # Audio file upload
|
|
|
|
| 32 |
],
|
| 33 |
outputs="text",
|
|
|
|
| 34 |
theme="huggingface",
|
| 35 |
title="Wav2Vec2-Bert demo - transcribe Czech Audio",
|
| 36 |
description=(
|