Spaces:
Runtime error
Runtime error
Commit
·
b922c32
1
Parent(s):
03f70d9
small fixes
Browse files
app.py
CHANGED
|
@@ -83,7 +83,26 @@ def show_file_info(in_filename: str):
|
|
| 83 |
_ = os.system(f"ffprobe -hide_banner -i '{in_filename}'")
|
| 84 |
|
| 85 |
|
| 86 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
language: str,
|
| 88 |
repo_id: str,
|
| 89 |
in_filename: str,
|
|
@@ -115,7 +134,6 @@ def process(language: str, repo_id: str, in_filename: str):
|
|
| 115 |
logging.info("Done")
|
| 116 |
|
| 117 |
return (
|
| 118 |
-
(in_filename, srt_filename),
|
| 119 |
srt_filename,
|
| 120 |
build_html_output("Done! Please download the SRT file", "result_item_success"),
|
| 121 |
result,
|
|
@@ -176,7 +194,6 @@ with demo:
|
|
| 176 |
)
|
| 177 |
upload_audio_button = gr.Button("Submit for recognition")
|
| 178 |
|
| 179 |
-
output_audio = gr.Audio(label="Output")
|
| 180 |
output_srt_file_audio = gr.File(
|
| 181 |
label="Generated subtitles", show_label=True
|
| 182 |
)
|
|
@@ -187,7 +204,7 @@ with demo:
|
|
| 187 |
)
|
| 188 |
|
| 189 |
upload_video_button.click(
|
| 190 |
-
|
| 191 |
inputs=[
|
| 192 |
language_radio,
|
| 193 |
model_dropdown,
|
|
@@ -209,7 +226,6 @@ with demo:
|
|
| 209 |
uploaded_audio_file,
|
| 210 |
],
|
| 211 |
outputs=[
|
| 212 |
-
output_audio,
|
| 213 |
output_srt_file_audio,
|
| 214 |
output_info_audio,
|
| 215 |
output_textbox_audio,
|
|
|
|
| 83 |
_ = os.system(f"ffprobe -hide_banner -i '{in_filename}'")
|
| 84 |
|
| 85 |
|
| 86 |
+
def process_uploaded_video_file(
|
| 87 |
+
language: str,
|
| 88 |
+
repo_id: str,
|
| 89 |
+
in_filename: str,
|
| 90 |
+
):
|
| 91 |
+
if in_filename is None or in_filename == "":
|
| 92 |
+
return "", build_html_output(
|
| 93 |
+
"Please first upload a file and then click "
|
| 94 |
+
'the button "submit for recognition"',
|
| 95 |
+
"result_item_error",
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
logging.info(f"Processing uploaded file: {in_filename}")
|
| 99 |
+
show_file_info(in_filename)
|
| 100 |
+
|
| 101 |
+
ans = process(language, repo_id, in_filename)
|
| 102 |
+
return (in_filename, ans[0]), ans[0], ans[1], ans[2]
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def process_uploaded_audio_file(
|
| 106 |
language: str,
|
| 107 |
repo_id: str,
|
| 108 |
in_filename: str,
|
|
|
|
| 134 |
logging.info("Done")
|
| 135 |
|
| 136 |
return (
|
|
|
|
| 137 |
srt_filename,
|
| 138 |
build_html_output("Done! Please download the SRT file", "result_item_success"),
|
| 139 |
result,
|
|
|
|
| 194 |
)
|
| 195 |
upload_audio_button = gr.Button("Submit for recognition")
|
| 196 |
|
|
|
|
| 197 |
output_srt_file_audio = gr.File(
|
| 198 |
label="Generated subtitles", show_label=True
|
| 199 |
)
|
|
|
|
| 204 |
)
|
| 205 |
|
| 206 |
upload_video_button.click(
|
| 207 |
+
process_uploaded_video_file,
|
| 208 |
inputs=[
|
| 209 |
language_radio,
|
| 210 |
model_dropdown,
|
|
|
|
| 226 |
uploaded_audio_file,
|
| 227 |
],
|
| 228 |
outputs=[
|
|
|
|
| 229 |
output_srt_file_audio,
|
| 230 |
output_info_audio,
|
| 231 |
output_textbox_audio,
|