Spaces:
Runtime error
Runtime error
Commit
·
683bbe8
1
Parent(s):
7fa3dcf
adjust
Browse files
adjust.py
CHANGED
|
@@ -101,7 +101,15 @@ def get_speakers_previous(to_name):
|
|
| 101 |
return get_current()
|
| 102 |
|
| 103 |
|
| 104 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
change_name(to_name)
|
| 106 |
|
| 107 |
# Replacing texts
|
|
@@ -113,18 +121,12 @@ def start_adjust(input_file, to_name, start_time, end_time, progress=gr.Progress
|
|
| 113 |
utils.write_transcribe_subtitle_file(
|
| 114 |
input_file, modified_transcribe, modified_subtitle, True)
|
| 115 |
|
| 116 |
-
# Adding subtitle to video
|
| 117 |
-
progress(0.8, desc=ui_lang["progress_add_subtitle"])
|
| 118 |
-
add_subtitle_to_video(
|
| 119 |
-
input_file, base_subtitle_adjusted_file, video_subtitle_file, start_time, end_time)
|
| 120 |
-
|
| 121 |
# Return video file link, transcribe string, transcribe.txt, subtitle.txt
|
| 122 |
transcribe_txt_list, _ = utils.read_transcribe_subtitle_file(
|
| 123 |
input_file, True)
|
| 124 |
print(line for line in transcribe_txt_list)
|
| 125 |
transcribe_txt = "\n".join(transcribe_txt_list)
|
| 126 |
return [
|
| 127 |
-
video_subtitle_file,
|
| 128 |
transcribe_txt,
|
| 129 |
[transcribe_adjusted_file, subtitle_adjusted_file]
|
| 130 |
]
|
|
|
|
| 101 |
return get_current()
|
| 102 |
|
| 103 |
|
| 104 |
+
def start_adjust_subtitle(input_file, start_time, end_time, progress=gr.Progress()):
|
| 105 |
+
# Adding subtitle to video
|
| 106 |
+
progress(0.8, desc=ui_lang["progress_add_subtitle"])
|
| 107 |
+
add_subtitle_to_video(
|
| 108 |
+
input_file, base_subtitle_adjusted_file, video_subtitle_file, start_time, end_time)
|
| 109 |
+
return video_subtitle_file
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def start_adjust(input_file, to_name, progress=gr.Progress()):
|
| 113 |
change_name(to_name)
|
| 114 |
|
| 115 |
# Replacing texts
|
|
|
|
| 121 |
utils.write_transcribe_subtitle_file(
|
| 122 |
input_file, modified_transcribe, modified_subtitle, True)
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
# Return video file link, transcribe string, transcribe.txt, subtitle.txt
|
| 125 |
transcribe_txt_list, _ = utils.read_transcribe_subtitle_file(
|
| 126 |
input_file, True)
|
| 127 |
print(line for line in transcribe_txt_list)
|
| 128 |
transcribe_txt = "\n".join(transcribe_txt_list)
|
| 129 |
return [
|
|
|
|
| 130 |
transcribe_txt,
|
| 131 |
[transcribe_adjusted_file, subtitle_adjusted_file]
|
| 132 |
]
|
app.py
CHANGED
|
@@ -38,9 +38,8 @@ with gr.Blocks() as demo:
|
|
| 38 |
output_video.render()
|
| 39 |
output_file.render()
|
| 40 |
output_file.change(prepare_output, inputs=input_video, outputs=[
|
| 41 |
-
adjust_speaker, adjust_audio, prev_button, next_button, adjust_button])
|
| 42 |
-
|
| 43 |
-
input_video, start_time, end_time], outputs=output_video)
|
| 44 |
|
| 45 |
with gr.Column():
|
| 46 |
output_transcribe.render()
|
|
@@ -59,8 +58,8 @@ with gr.Blocks() as demo:
|
|
| 59 |
adjust_speaker, adjust_audio])
|
| 60 |
|
| 61 |
adjust_button.render()
|
| 62 |
-
adjust_button.click(start_adjust, inputs=[input_video, adjust_speaker
|
| 63 |
-
|
| 64 |
|
| 65 |
with gr.Accordion("Copyright"):
|
| 66 |
gr.Markdown("Created with OpenAI Whisper and Huggingface")
|
|
|
|
| 38 |
output_video.render()
|
| 39 |
output_file.render()
|
| 40 |
output_file.change(prepare_output, inputs=input_video, outputs=[
|
| 41 |
+
adjust_speaker, adjust_audio, prev_button, next_button, adjust_button]).then(prepare_video_subtitle, inputs=[
|
| 42 |
+
input_video, start_time, end_time], outputs=output_video)
|
|
|
|
| 43 |
|
| 44 |
with gr.Column():
|
| 45 |
output_transcribe.render()
|
|
|
|
| 58 |
adjust_speaker, adjust_audio])
|
| 59 |
|
| 60 |
adjust_button.render()
|
| 61 |
+
adjust_button.click(start_adjust, inputs=[input_video, adjust_speaker], outputs=[output_transcribe, output_file]).then(
|
| 62 |
+
start_adjust_subtitle, inputs=[input_video, start_time, end_time], outputs=output_video)
|
| 63 |
|
| 64 |
with gr.Accordion("Copyright"):
|
| 65 |
gr.Markdown("Created with OpenAI Whisper and Huggingface")
|