Spaces:
Runtime error
Runtime error
Commit
·
a497221
1
Parent(s):
fb7a690
change warning to error
Browse files
app.py
CHANGED
@@ -33,8 +33,8 @@ with gr.Blocks() as demo:
|
|
33 |
(
|
34 |
start_button
|
35 |
.click(prepare_input, [input_video, start_time, end_time, lang_radio, model_dropdown], [output_transcribe, output_file])
|
36 |
-
.
|
37 |
-
.
|
38 |
)
|
39 |
|
40 |
bottom_markdown.render()
|
@@ -63,7 +63,7 @@ with gr.Blocks() as demo:
|
|
63 |
(
|
64 |
adjust_button
|
65 |
.click(start_adjust, inputs=[input_video, adjust_speaker], outputs=[output_transcribe, output_file])
|
66 |
-
.
|
67 |
)
|
68 |
|
69 |
with gr.Accordion("Copyright"):
|
|
|
33 |
(
|
34 |
start_button
|
35 |
.click(prepare_input, [input_video, start_time, end_time, lang_radio, model_dropdown], [output_transcribe, output_file])
|
36 |
+
.success(prepare_output, inputs=input_video, outputs=[adjust_speaker, adjust_audio, prev_button, next_button, adjust_button])
|
37 |
+
.success(prepare_video_subtitle, inputs=[input_video, start_time, end_time], outputs=output_video)
|
38 |
)
|
39 |
|
40 |
bottom_markdown.render()
|
|
|
63 |
(
|
64 |
adjust_button
|
65 |
.click(start_adjust, inputs=[input_video, adjust_speaker], outputs=[output_transcribe, output_file])
|
66 |
+
.success(start_adjust_subtitle, inputs=[input_video, start_time, end_time], outputs=output_video)
|
67 |
)
|
68 |
|
69 |
with gr.Accordion("Copyright"):
|
set_up.py
CHANGED
@@ -12,14 +12,13 @@ import utils
|
|
12 |
|
13 |
def prepare_video_subtitle(input_file, start_time, end_time, progress=gr.Progress()):
|
14 |
if input_file is None or not os.path.exists(input_file):
|
15 |
-
gr.
|
16 |
-
return [None, None, [None, None]]
|
17 |
if validate_time_format(start_time) is False:
|
18 |
-
gr.
|
19 |
-
return [None, None, [None, None]]
|
20 |
if validate_time_format(end_time) is False:
|
21 |
-
gr.
|
22 |
-
|
|
|
23 |
# Add subtitle to video
|
24 |
progress(0.8, desc=ui_lang["progress_add_subtitle"])
|
25 |
add_subtitle_to_video(input_file, base_subtitle_file,
|
@@ -31,23 +30,17 @@ def prepare_input(input_file, start_time, end_time, lang, model_size, progress=g
|
|
31 |
gr.Info(ui_lang["progress_starting_process"])
|
32 |
|
33 |
if input_file is None or not os.path.exists(input_file):
|
34 |
-
gr.
|
35 |
-
return [None, None, [None, None]]
|
36 |
if validate_time_format(start_time) is False:
|
37 |
-
gr.
|
38 |
-
|
39 |
-
|
40 |
-
gr.Warning(ui_lang["end_time_warning"])
|
41 |
-
return [None, None, [None, None]]
|
42 |
if (check_if_time_invalid(start_time, end_time)):
|
43 |
-
gr.
|
44 |
-
return [None, None, [None, None]]
|
45 |
if lang is None:
|
46 |
-
gr.
|
47 |
-
return [None, None, [None, None]]
|
48 |
if model_size is None:
|
49 |
-
gr.
|
50 |
-
return [None, None, [None, None]]
|
51 |
|
52 |
print(f"SOURCE: {input_file}")
|
53 |
print(f"AUDIO FILE: {audio_file}")
|
|
|
12 |
|
13 |
def prepare_video_subtitle(input_file, start_time, end_time, progress=gr.Progress()):
|
14 |
if input_file is None or not os.path.exists(input_file):
|
15 |
+
raise gr.Error(ui_lang["input_video_warning"])
|
|
|
16 |
if validate_time_format(start_time) is False:
|
17 |
+
raise gr.Error(ui_lang["start_time_warning"])
|
|
|
18 |
if validate_time_format(end_time) is False:
|
19 |
+
raise gr.Error(ui_lang["end_time_warning"])
|
20 |
+
if (check_if_time_invalid(start_time, end_time)):
|
21 |
+
raise gr.Error(ui_lang["time_invalid"])
|
22 |
# Add subtitle to video
|
23 |
progress(0.8, desc=ui_lang["progress_add_subtitle"])
|
24 |
add_subtitle_to_video(input_file, base_subtitle_file,
|
|
|
30 |
gr.Info(ui_lang["progress_starting_process"])
|
31 |
|
32 |
if input_file is None or not os.path.exists(input_file):
|
33 |
+
raise gr.Error(ui_lang["input_video_warning"])
|
|
|
34 |
if validate_time_format(start_time) is False:
|
35 |
+
raise gr.Error(ui_lang["start_time_warning"])
|
36 |
+
if validate_time_format(end_time) is False:
|
37 |
+
raise gr.Error(ui_lang["end_time_warning"])
|
|
|
|
|
38 |
if (check_if_time_invalid(start_time, end_time)):
|
39 |
+
raise gr.Error(ui_lang["time_invalid"])
|
|
|
40 |
if lang is None:
|
41 |
+
raise gr.Error(ui_lang["lang_radio_warning"])
|
|
|
42 |
if model_size is None:
|
43 |
+
raise gr.Error(ui_lang["model_dropdown_warning"])
|
|
|
44 |
|
45 |
print(f"SOURCE: {input_file}")
|
46 |
print(f"AUDIO FILE: {audio_file}")
|
ui.py
CHANGED
@@ -74,8 +74,7 @@ def get_video_from_url(url):
|
|
74 |
url, file_name.download_file, quiet=False, fuzzy=True)
|
75 |
|
76 |
if (download_result is None):
|
77 |
-
gr.
|
78 |
-
return None
|
79 |
|
80 |
gr.Info(ui_lang["get_video_finished_info"])
|
81 |
return file_name.download_file
|
@@ -91,11 +90,7 @@ def get_video_from_url(url):
|
|
91 |
# def get_duration(input_file):
|
92 |
# print("Checking file")
|
93 |
# if input_file is None:
|
94 |
-
# gr.
|
95 |
-
# return [
|
96 |
-
# start_time.update(None, interactive=False),
|
97 |
-
# end_time.update(None, interactive=False)
|
98 |
-
# ]
|
99 |
# print("Getting duration & Waiting")
|
100 |
# info_json = ffmpeg.probe(input_file)
|
101 |
# print("Probing finished")
|
|
|
74 |
url, file_name.download_file, quiet=False, fuzzy=True)
|
75 |
|
76 |
if (download_result is None):
|
77 |
+
raise gr.Error(ui_lang["get_video_fail_info"])
|
|
|
78 |
|
79 |
gr.Info(ui_lang["get_video_finished_info"])
|
80 |
return file_name.download_file
|
|
|
90 |
# def get_duration(input_file):
|
91 |
# print("Checking file")
|
92 |
# if input_file is None:
|
93 |
+
# raise gr.Error(ui_lang["input_video_warning"])
|
|
|
|
|
|
|
|
|
94 |
# print("Getting duration & Waiting")
|
95 |
# info_json = ffmpeg.probe(input_file)
|
96 |
# print("Probing finished")
|