Spaces:
Running
on
Zero
Running
on
Zero
Fix and add ZeroGPU support
#137
by
multimodalart
HF Staff
- opened
README.md
CHANGED
@@ -4,9 +4,9 @@ emoji: 📉
|
|
4 |
colorFrom: pink
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
4 |
colorFrom: pink
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.46.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import torch
|
2 |
|
|
|
3 |
import gradio as gr
|
4 |
import yt_dlp as youtube_dl
|
5 |
from transformers import pipeline
|
@@ -22,7 +23,7 @@ pipe = pipeline(
|
|
22 |
device=device,
|
23 |
)
|
24 |
|
25 |
-
|
26 |
def transcribe(inputs, task):
|
27 |
if inputs is None:
|
28 |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
|
@@ -70,7 +71,7 @@ def download_yt_audio(yt_url, filename):
|
|
70 |
except youtube_dl.utils.ExtractorError as err:
|
71 |
raise gr.Error(str(err))
|
72 |
|
73 |
-
|
74 |
def yt_transcribe(yt_url, task, max_filesize=75.0):
|
75 |
html_embed_str = _return_yt_html_embed(yt_url)
|
76 |
|
@@ -88,35 +89,13 @@ def yt_transcribe(yt_url, task, max_filesize=75.0):
|
|
88 |
return html_embed_str, text
|
89 |
|
90 |
|
91 |
-
demo = gr.
|
92 |
-
|
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: Transcribe Audio",
|
103 |
-
description=(
|
104 |
-
"Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the OpenAI Whisper"
|
105 |
-
f" checkpoint [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to transcribe audio files"
|
106 |
-
" of arbitrary length."
|
107 |
-
),
|
108 |
-
allow_flagging="never",
|
109 |
-
)
|
110 |
-
|
111 |
-
file_transcribe = gr.Interface(
|
112 |
fn=transcribe,
|
113 |
inputs=[
|
114 |
-
gr.
|
115 |
-
gr.
|
116 |
],
|
117 |
-
outputs=
|
118 |
-
layout="horizontal",
|
119 |
-
theme="huggingface",
|
120 |
title="Whisper Large V3: Transcribe Audio",
|
121 |
description=(
|
122 |
"Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the OpenAI Whisper"
|
@@ -126,26 +105,4 @@ file_transcribe = gr.Interface(
|
|
126 |
allow_flagging="never",
|
127 |
)
|
128 |
|
129 |
-
|
130 |
-
fn=yt_transcribe,
|
131 |
-
inputs=[
|
132 |
-
gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"),
|
133 |
-
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe")
|
134 |
-
],
|
135 |
-
outputs=["html", "text"],
|
136 |
-
layout="horizontal",
|
137 |
-
theme="huggingface",
|
138 |
-
title="Whisper Large V3: Transcribe YouTube",
|
139 |
-
description=(
|
140 |
-
"Transcribe long-form YouTube videos with the click of a button! Demo uses the OpenAI Whisper checkpoint"
|
141 |
-
f" [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to transcribe video files of"
|
142 |
-
" arbitrary length."
|
143 |
-
),
|
144 |
-
allow_flagging="never",
|
145 |
-
)
|
146 |
-
|
147 |
-
with demo:
|
148 |
-
gr.TabbedInterface([mf_transcribe, file_transcribe, yt_transcribe], ["Microphone", "Audio file", "YouTube"])
|
149 |
-
|
150 |
-
demo.launch(enable_queue=True)
|
151 |
-
|
|
|
1 |
import torch
|
2 |
|
3 |
+
import spaces
|
4 |
import gradio as gr
|
5 |
import yt_dlp as youtube_dl
|
6 |
from transformers import pipeline
|
|
|
23 |
device=device,
|
24 |
)
|
25 |
|
26 |
+
@spaces.GPU
|
27 |
def transcribe(inputs, task):
|
28 |
if inputs is None:
|
29 |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
|
|
|
71 |
except youtube_dl.utils.ExtractorError as err:
|
72 |
raise gr.Error(str(err))
|
73 |
|
74 |
+
@spaces.GPU
|
75 |
def yt_transcribe(yt_url, task, max_filesize=75.0):
|
76 |
html_embed_str = _return_yt_html_embed(yt_url)
|
77 |
|
|
|
89 |
return html_embed_str, text
|
90 |
|
91 |
|
92 |
+
demo = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
fn=transcribe,
|
94 |
inputs=[
|
95 |
+
gr.Audio(type="filepath"),
|
96 |
+
gr.Radio(["transcribe", "translate"], label="Task", value="transcribe"),
|
97 |
],
|
98 |
+
outputs=gr.Textbox(lines=3),
|
|
|
|
|
99 |
title="Whisper Large V3: Transcribe Audio",
|
100 |
description=(
|
101 |
"Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the OpenAI Whisper"
|
|
|
105 |
allow_flagging="never",
|
106 |
)
|
107 |
|
108 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|