Spaces:
Sleeping
Sleeping
Ziyou Li
commited on
Commit
•
1ca6ac9
1
Parent(s):
98e9809
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
import os
|
4 |
import subprocess
|
5 |
from pytube import YouTube
|
|
|
6 |
|
7 |
pipe = pipeline(model="tilos/whisper-small-zh-HK") # change to "your-username/the-name-you-picked"
|
8 |
|
@@ -17,6 +18,9 @@ def transcribe(audio):
|
|
17 |
text = pipe(audio)["text"]
|
18 |
return text
|
19 |
|
|
|
|
|
|
|
20 |
|
21 |
def get_text(url):
|
22 |
result = pipe(get_audio(url))
|
@@ -37,6 +41,7 @@ def offline_video(video):
|
|
37 |
text = transcribe(audio_file)
|
38 |
return text
|
39 |
|
|
|
40 |
|
41 |
with gr.Blocks() as demo:
|
42 |
|
@@ -51,6 +56,15 @@ with gr.Blocks() as demo:
|
|
51 |
allow_flagging="never",
|
52 |
)
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
# audio file input
|
55 |
with gr.Row():
|
56 |
with gr.Column():
|
|
|
3 |
import os
|
4 |
import subprocess
|
5 |
from pytube import YouTube
|
6 |
+
import subprocess
|
7 |
|
8 |
pipe = pipeline(model="tilos/whisper-small-zh-HK") # change to "your-username/the-name-you-picked"
|
9 |
|
|
|
18 |
text = pipe(audio)["text"]
|
19 |
return text
|
20 |
|
21 |
+
def gen_sub(video):
|
22 |
+
result = subprocess.check_output(['auto_subtitle',video,'--model', 'medium'])
|
23 |
+
return text
|
24 |
|
25 |
def get_text(url):
|
26 |
result = pipe(get_audio(url))
|
|
|
41 |
text = transcribe(audio_file)
|
42 |
return text
|
43 |
|
44 |
+
def
|
45 |
|
46 |
with gr.Blocks() as demo:
|
47 |
|
|
|
56 |
allow_flagging="never",
|
57 |
)
|
58 |
|
59 |
+
# audio file input, generate subtitled video
|
60 |
+
gr.Interface(
|
61 |
+
description= "Generate Cantonese subtitled video from video file",
|
62 |
+
fn=gen_sub,
|
63 |
+
inputs="video",
|
64 |
+
outputs="video",
|
65 |
+
allow_flagging="never",
|
66 |
+
)
|
67 |
+
|
68 |
# audio file input
|
69 |
with gr.Row():
|
70 |
with gr.Column():
|