csukuangfj
commited on
Commit
•
03b48c7
1
Parent(s):
f0a085b
output video
Browse files
app.py
CHANGED
@@ -22,6 +22,7 @@
|
|
22 |
|
23 |
import logging
|
24 |
import os
|
|
|
25 |
|
26 |
import gradio as gr
|
27 |
|
@@ -98,7 +99,16 @@ def process_uploaded_file(
|
|
98 |
|
99 |
result = decode(recognizer, vad, in_filename)
|
100 |
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
|
104 |
demo = gr.Blocks(css=css)
|
@@ -135,6 +145,7 @@ with demo:
|
|
135 |
show_share_button=True,
|
136 |
)
|
137 |
upload_button = gr.Button("Submit for recognition")
|
|
|
138 |
uploaded_output = gr.Textbox(label="Recognized speech from uploaded file")
|
139 |
uploaded_html_info = gr.HTML(label="Info")
|
140 |
|
@@ -145,7 +156,12 @@ with demo:
|
|
145 |
model_dropdown,
|
146 |
uploaded_file,
|
147 |
],
|
148 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
149 |
)
|
150 |
|
151 |
gr.Markdown(description)
|
|
|
22 |
|
23 |
import logging
|
24 |
import os
|
25 |
+
from pathlib import Path
|
26 |
|
27 |
import gradio as gr
|
28 |
|
|
|
99 |
|
100 |
result = decode(recognizer, vad, in_filename)
|
101 |
|
102 |
+
srt_filename = Path(in_filename).with_suffix(".srt")
|
103 |
+
with open(srt_filename, "w", encoding="utf-8") as f:
|
104 |
+
f.write(result)
|
105 |
+
|
106 |
+
return (
|
107 |
+
(in_filename, srt_filename),
|
108 |
+
srt_filename,
|
109 |
+
result,
|
110 |
+
build_html_output("Done! Please download the SRT file", "result_item_success"),
|
111 |
+
)
|
112 |
|
113 |
|
114 |
demo = gr.Blocks(css=css)
|
|
|
145 |
show_share_button=True,
|
146 |
)
|
147 |
upload_button = gr.Button("Submit for recognition")
|
148 |
+
video_output_for_upload = gr.Video(label="Output")
|
149 |
uploaded_output = gr.Textbox(label="Recognized speech from uploaded file")
|
150 |
uploaded_html_info = gr.HTML(label="Info")
|
151 |
|
|
|
156 |
model_dropdown,
|
157 |
uploaded_file,
|
158 |
],
|
159 |
+
outputs=[
|
160 |
+
gr.Video(label="Output"),
|
161 |
+
gr.File(label="Generated subtitles", show_label=True),
|
162 |
+
uploaded_output,
|
163 |
+
uploaded_html_info,
|
164 |
+
],
|
165 |
)
|
166 |
|
167 |
gr.Markdown(description)
|