Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -21,18 +21,8 @@ transcribe_token_id = all_special_ids[-5]
|
|
21 |
translate_token_id = all_special_ids[-6]
|
22 |
|
23 |
|
24 |
-
def transcribe(microphone,
|
25 |
-
|
26 |
-
if (microphone is not None) and (file_upload is not None):
|
27 |
-
warn_output = (
|
28 |
-
"WARNING: You've uploaded an audio file and used the microphone. "
|
29 |
-
"The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
|
30 |
-
)
|
31 |
-
|
32 |
-
elif (microphone is None) and (file_upload is None):
|
33 |
-
return "ERROR: You have to either use the microphone or upload an audio file"
|
34 |
-
|
35 |
-
file = microphone if microphone is not None else file_upload
|
36 |
|
37 |
pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="transcribe" else translate_token_id]]
|
38 |
|
@@ -68,9 +58,8 @@ demo = gr.Blocks()
|
|
68 |
mf_transcribe = gr.Interface(
|
69 |
fn=transcribe,
|
70 |
inputs=[
|
71 |
-
gr.
|
72 |
-
gr.
|
73 |
-
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
74 |
],
|
75 |
outputs="text",
|
76 |
layout="horizontal",
|
@@ -84,26 +73,8 @@ mf_transcribe = gr.Interface(
|
|
84 |
allow_flagging="never",
|
85 |
)
|
86 |
|
87 |
-
yt_transcribe = gr.Interface(
|
88 |
-
fn=yt_transcribe,
|
89 |
-
inputs=[
|
90 |
-
gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"),
|
91 |
-
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe")
|
92 |
-
],
|
93 |
-
outputs=["html", "text"],
|
94 |
-
layout="horizontal",
|
95 |
-
theme="huggingface",
|
96 |
-
title="Whisper Large V2: Transcribe YouTube",
|
97 |
-
description=(
|
98 |
-
"Transcribe long-form YouTube videos with the click of a button! Demo uses the checkpoint"
|
99 |
-
f" [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to transcribe video files of"
|
100 |
-
" arbitrary length."
|
101 |
-
),
|
102 |
-
allow_flagging="never",
|
103 |
-
)
|
104 |
|
105 |
-
|
106 |
-
gr.TabbedInterface([mf_transcribe, yt_transcribe], ["Transcribe Audio", "Transcribe YouTube"])
|
107 |
|
108 |
demo.launch(enable_queue=True)
|
109 |
|
|
|
21 |
translate_token_id = all_special_ids[-6]
|
22 |
|
23 |
|
24 |
+
def transcribe(microphone, task):
|
25 |
+
file = microphone
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="transcribe" else translate_token_id]]
|
28 |
|
|
|
58 |
mf_transcribe = gr.Interface(
|
59 |
fn=transcribe,
|
60 |
inputs=[
|
61 |
+
gr.Audio(source="microphone", type="filepath", optional=True),
|
62 |
+
gr.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
|
|
63 |
],
|
64 |
outputs="text",
|
65 |
layout="horizontal",
|
|
|
73 |
allow_flagging="never",
|
74 |
)
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
|
|
|
78 |
|
79 |
demo.launch(enable_queue=True)
|
80 |
|