Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
-
|
4 |
-
import tempfile
|
5 |
-
import os
|
6 |
pipe = pipeline(model="PatrickML/whisper_small")
|
7 |
def transcribe(audio):
|
8 |
text = pipe(audio)["text"]
|
@@ -11,22 +9,3 @@ def transcribe(audio):
|
|
11 |
mic = gr.Audio(source="microphone", type="filepath", label="Speak here...")
|
12 |
iface = gr.Interface(transcribe,mic,"text").launch()
|
13 |
|
14 |
-
def transcribe_video(video_url):
|
15 |
-
temp_video_file = tempfile.NamedTemporaryFile(delete=False)
|
16 |
-
urllib.request.urlretrieve(video_url, temp_video_file.name)
|
17 |
-
|
18 |
-
text = pipe(temp_video_file.name)["text"]
|
19 |
-
|
20 |
-
os.remove(temp_video_file.name)
|
21 |
-
|
22 |
-
return text
|
23 |
-
|
24 |
-
video_input = gr.Interface(
|
25 |
-
fn=transcribe_video,
|
26 |
-
inputs=gr.inputs.Textbox(label="输入视频URL"),
|
27 |
-
outputs=gr.outputs.Textbox(label="文本转录结果"),
|
28 |
-
live=True,
|
29 |
-
)
|
30 |
-
|
31 |
-
# 启动Web应用程序
|
32 |
-
video_input.launch()
|
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
+
|
|
|
|
|
4 |
pipe = pipeline(model="PatrickML/whisper_small")
|
5 |
def transcribe(audio):
|
6 |
text = pipe(audio)["text"]
|
|
|
9 |
mic = gr.Audio(source="microphone", type="filepath", label="Speak here...")
|
10 |
iface = gr.Interface(transcribe,mic,"text").launch()
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|