Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,19 +25,19 @@ pipe = pipeline(
|
|
| 25 |
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
|
| 26 |
|
| 27 |
@spaces.GPU(duration=120)
|
| 28 |
-
def transcribe(microphone, file_upload):
|
| 29 |
pipe.to(device)
|
| 30 |
warn_output = ""
|
| 31 |
-
if (microphone is not None) and (file_upload is not None):
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
|
| 37 |
-
elif (microphone is None) and (file_upload is None):
|
| 38 |
-
|
| 39 |
|
| 40 |
-
file = microphone if microphone is not None else file_upload
|
| 41 |
|
| 42 |
text = pipe(file)["text"]
|
| 43 |
|
|
@@ -69,8 +69,7 @@ demo = gr.Blocks()
|
|
| 69 |
mf_transcribe = gr.Interface(
|
| 70 |
fn=transcribe,
|
| 71 |
inputs=[
|
| 72 |
-
gr.components.Audio(
|
| 73 |
-
gr.components.Audio(source="upload", type="filepath", optional=True),
|
| 74 |
],
|
| 75 |
outputs="text",
|
| 76 |
layout="horizontal",
|
|
|
|
| 25 |
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
|
| 26 |
|
| 27 |
@spaces.GPU(duration=120)
|
| 28 |
+
def transcribe(file): #microphone, file_upload):
|
| 29 |
pipe.to(device)
|
| 30 |
warn_output = ""
|
| 31 |
+
# if (microphone is not None) and (file_upload is not None):
|
| 32 |
+
# warn_output = (
|
| 33 |
+
# "WARNING: You've uploaded an audio file and used the microphone. "
|
| 34 |
+
# "The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
|
| 35 |
+
# )
|
| 36 |
|
| 37 |
+
# elif (microphone is None) and (file_upload is None):
|
| 38 |
+
# return "ERROR: You have to either use the microphone or upload an audio file"
|
| 39 |
|
| 40 |
+
# file = microphone if microphone is not None else file_upload
|
| 41 |
|
| 42 |
text = pipe(file)["text"]
|
| 43 |
|
|
|
|
| 69 |
mf_transcribe = gr.Interface(
|
| 70 |
fn=transcribe,
|
| 71 |
inputs=[
|
| 72 |
+
gr.components.Audio(sources=['upload', 'microphone'], type="filepath", optional=True),
|
|
|
|
| 73 |
],
|
| 74 |
outputs="text",
|
| 75 |
layout="horizontal",
|