Spaces:
Sleeping
Sleeping
Downgrade
Browse files- README.md +1 -1
- app.py +26 -32
- requirements.txt +1 -0
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: 🔥
|
|
4 |
colorFrom: pink
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
4 |
colorFrom: pink
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.38.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
CHANGED
@@ -18,14 +18,14 @@ device = 0 if torch.cuda.is_available() else "cpu"
|
|
18 |
pipe = pipeline(
|
19 |
task="automatic-speech-recognition",
|
20 |
model=MODEL_NAME,
|
21 |
-
chunk_length_s=
|
22 |
device=device,
|
23 |
)
|
24 |
|
25 |
|
26 |
def transcribe(inputs, task):
|
27 |
if inputs is None:
|
28 |
-
raise gr.Error("Fayl
|
29 |
|
30 |
text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
|
31 |
return text
|
@@ -60,7 +60,7 @@ def download_yt_audio(yt_url, filename):
|
|
60 |
if file_length_s > YT_LENGTH_LIMIT_S:
|
61 |
yt_length_limit_hms = time.strftime("%HH:%MM:%SS", time.gmtime(YT_LENGTH_LIMIT_S))
|
62 |
file_length_hms = time.strftime("%HH:%MM:%SS", time.gmtime(file_length_s))
|
63 |
-
raise gr.Error(f"
|
64 |
|
65 |
ydl_opts = {"outtmpl": filename, "format": "worstvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"}
|
66 |
|
@@ -93,52 +93,46 @@ demo = gr.Blocks()
|
|
93 |
mf_transcribe = gr.Interface(
|
94 |
fn=transcribe,
|
95 |
inputs=[
|
96 |
-
gr.Audio(
|
97 |
-
gr.Radio(["transcribe", "translate"], label="Task",
|
98 |
],
|
99 |
outputs="text",
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
),
|
106 |
-
flagging_mode="never",
|
107 |
)
|
108 |
|
109 |
file_transcribe = gr.Interface(
|
110 |
fn=transcribe,
|
111 |
inputs=[
|
112 |
-
gr.Audio(
|
113 |
-
gr.Radio(["transcribe", "translate"], label="Task",
|
114 |
],
|
115 |
outputs="text",
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
),
|
122 |
-
flagging_mode="never",
|
123 |
)
|
124 |
|
125 |
yt_transcribe = gr.Interface(
|
126 |
fn=yt_transcribe,
|
127 |
inputs=[
|
128 |
-
gr.Textbox(lines=1, placeholder="
|
129 |
-
gr.Radio(["transcribe", "translate"], label="Task",
|
130 |
],
|
131 |
outputs=["html", "text"],
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
),
|
138 |
-
flagging_mode="never",
|
139 |
)
|
140 |
|
141 |
with demo:
|
142 |
-
gr.TabbedInterface([mf_transcribe, file_transcribe, yt_transcribe], ["
|
143 |
|
144 |
-
demo.launch()
|
|
|
18 |
pipe = pipeline(
|
19 |
task="automatic-speech-recognition",
|
20 |
model=MODEL_NAME,
|
21 |
+
chunk_length_s=30,
|
22 |
device=device,
|
23 |
)
|
24 |
|
25 |
|
26 |
def transcribe(inputs, task):
|
27 |
if inputs is None:
|
28 |
+
raise gr.Error("Fayl yuklanmadi.")
|
29 |
|
30 |
text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
|
31 |
return text
|
|
|
60 |
if file_length_s > YT_LENGTH_LIMIT_S:
|
61 |
yt_length_limit_hms = time.strftime("%HH:%MM:%SS", time.gmtime(YT_LENGTH_LIMIT_S))
|
62 |
file_length_hms = time.strftime("%HH:%MM:%SS", time.gmtime(file_length_s))
|
63 |
+
raise gr.Error(f"Youtube video limit {yt_length_limit_hms}, bu video uzunligi {file_length_hms}.")
|
64 |
|
65 |
ydl_opts = {"outtmpl": filename, "format": "worstvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"}
|
66 |
|
|
|
93 |
mf_transcribe = gr.Interface(
|
94 |
fn=transcribe,
|
95 |
inputs=[
|
96 |
+
gr.inputs.Audio(source="microphone", type="filepath", optional=True),
|
97 |
+
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
98 |
],
|
99 |
outputs="text",
|
100 |
+
layout="horizontal",
|
101 |
+
theme="huggingface",
|
102 |
+
title="Whisper Large V3 - O'zbek tili",
|
103 |
+
description="",
|
104 |
+
allow_flagging="never",
|
|
|
|
|
105 |
)
|
106 |
|
107 |
file_transcribe = gr.Interface(
|
108 |
fn=transcribe,
|
109 |
inputs=[
|
110 |
+
gr.inputs.Audio(source="upload", type="filepath", optional=True, label="Audio fayl"),
|
111 |
+
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
112 |
],
|
113 |
outputs="text",
|
114 |
+
layout="horizontal",
|
115 |
+
theme="huggingface",
|
116 |
+
title="Whisper Large V3 - O'zbek tili",
|
117 |
+
description="",
|
118 |
+
allow_flagging="never",
|
|
|
|
|
119 |
)
|
120 |
|
121 |
yt_transcribe = gr.Interface(
|
122 |
fn=yt_transcribe,
|
123 |
inputs=[
|
124 |
+
gr.inputs.Textbox(lines=1, placeholder="Youtbe video linkini tashlang", label="YouTube URL"),
|
125 |
+
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe")
|
126 |
],
|
127 |
outputs=["html", "text"],
|
128 |
+
layout="horizontal",
|
129 |
+
theme="huggingface",
|
130 |
+
title="Whisper Large V3 - O'zbek tili",
|
131 |
+
description="",
|
132 |
+
allow_flagging="never",
|
|
|
|
|
133 |
)
|
134 |
|
135 |
with demo:
|
136 |
+
gr.TabbedInterface([mf_transcribe, file_transcribe, yt_transcribe], ["Mikrofon", "Audio fayl", "YouTube"])
|
137 |
|
138 |
+
demo.launch(enable_queue=True)
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
transformers
|
2 |
torch
|
3 |
yt-dlp
|
|
|
|
1 |
transformers
|
2 |
torch
|
3 |
yt-dlp
|
4 |
+
gradio==3.38.0
|