upd to new gradio version
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import pytube as pt
|
|
5 |
from transformers import pipeline
|
6 |
from huggingface_hub import model_info
|
7 |
|
8 |
-
MODEL_NAME = "ales/whisper-small-belarusian"
|
9 |
lang = "be"
|
10 |
|
11 |
device = 0 if torch.cuda.is_available() else "cpu"
|
@@ -17,7 +17,10 @@ pipe = pipeline(
|
|
17 |
device=device,
|
18 |
)
|
19 |
|
20 |
-
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(
|
|
|
|
|
|
|
21 |
|
22 |
def transcribe(microphone, file_upload):
|
23 |
warn_output = ""
|
@@ -61,10 +64,7 @@ demo = gr.Blocks()
|
|
61 |
|
62 |
mf_transcribe = gr.Interface(
|
63 |
fn=transcribe,
|
64 |
-
inputs=[
|
65 |
-
gr.inputs.Audio(source="microphone", type="filepath", optional=True),
|
66 |
-
gr.inputs.Audio(source="upload", type="filepath", optional=True),
|
67 |
-
],
|
68 |
outputs="text",
|
69 |
layout="horizontal",
|
70 |
theme="huggingface",
|
@@ -79,7 +79,13 @@ mf_transcribe = gr.Interface(
|
|
79 |
|
80 |
yt_transcribe = gr.Interface(
|
81 |
fn=yt_transcribe,
|
82 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
outputs=["html", "text"],
|
84 |
layout="horizontal",
|
85 |
theme="huggingface",
|
@@ -93,6 +99,8 @@ yt_transcribe = gr.Interface(
|
|
93 |
)
|
94 |
|
95 |
with demo:
|
96 |
-
gr.TabbedInterface(
|
|
|
|
|
97 |
|
98 |
demo.launch(enable_queue=True)
|
|
|
5 |
from transformers import pipeline
|
6 |
from huggingface_hub import model_info
|
7 |
|
8 |
+
MODEL_NAME = "ales/whisper-small-belarusian" # this always needs to stay in line 8 :D sorry for the hackiness
|
9 |
lang = "be"
|
10 |
|
11 |
device = 0 if torch.cuda.is_available() else "cpu"
|
|
|
17 |
device=device,
|
18 |
)
|
19 |
|
20 |
+
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(
|
21 |
+
language=lang, task="transcribe"
|
22 |
+
)
|
23 |
+
|
24 |
|
25 |
def transcribe(microphone, file_upload):
|
26 |
warn_output = ""
|
|
|
64 |
|
65 |
mf_transcribe = gr.Interface(
|
66 |
fn=transcribe,
|
67 |
+
inputs=[gr.Audio(sources=["microphone", "upload"], type="filepath", optional=True)],
|
|
|
|
|
|
|
68 |
outputs="text",
|
69 |
layout="horizontal",
|
70 |
theme="huggingface",
|
|
|
79 |
|
80 |
yt_transcribe = gr.Interface(
|
81 |
fn=yt_transcribe,
|
82 |
+
inputs=[
|
83 |
+
gr.Textbox(
|
84 |
+
lines=1,
|
85 |
+
placeholder="Paste the URL to a YouTube video here",
|
86 |
+
label="YouTube URL",
|
87 |
+
)
|
88 |
+
],
|
89 |
outputs=["html", "text"],
|
90 |
layout="horizontal",
|
91 |
theme="huggingface",
|
|
|
99 |
)
|
100 |
|
101 |
with demo:
|
102 |
+
gr.TabbedInterface(
|
103 |
+
[mf_transcribe, yt_transcribe], ["Transcribe Audio", "Transcribe YouTube"]
|
104 |
+
)
|
105 |
|
106 |
demo.launch(enable_queue=True)
|