Spaces:
Paused
Paused
Update app_srt.py
Browse files- app_srt.py +7 -4
app_srt.py
CHANGED
@@ -542,6 +542,9 @@ def merge_audios(input_dir):
|
|
542 |
def convert_from_srt(filename, video_full, language, split_model, multilingual):
|
543 |
subtitle_list = read_srt(filename)
|
544 |
|
|
|
|
|
|
|
545 |
ffmpeg.input(video_full).output("audio_full.wav", ac=2, ar=44100).run()
|
546 |
|
547 |
if split_model=="UVR-HP2":
|
@@ -549,7 +552,7 @@ def convert_from_srt(filename, video_full, language, split_model, multilingual):
|
|
549 |
else:
|
550 |
pre_fun = pre_fun_hp5
|
551 |
|
552 |
-
pre_fun._path_audio_("audio_full.wav", f"./denoised/{split_model}/{
|
553 |
|
554 |
shutil.rmtree("output")
|
555 |
shutil.rmtree("sliced")
|
@@ -557,7 +560,7 @@ def convert_from_srt(filename, video_full, language, split_model, multilingual):
|
|
557 |
for i in subtitle_list:
|
558 |
os.makedirs("output", exist_ok=True)
|
559 |
os.makedirs("sliced", exist_ok=True)
|
560 |
-
trim_audio([[i.start_time, i.end_time]], f"./denoised/{split_model}/{
|
561 |
print(f"正在合成第{i.index}条语音")
|
562 |
print(f"语音内容:{i.text}")
|
563 |
predict(i.text, language, f"./sliced/sliced_audio_{i.index}_0.wav", i.text + " " + str(i.index))
|
@@ -565,7 +568,7 @@ def convert_from_srt(filename, video_full, language, split_model, multilingual):
|
|
565 |
for i in subtitle_list:
|
566 |
os.makedirs("output", exist_ok=True)
|
567 |
os.makedirs("sliced", exist_ok=True)
|
568 |
-
trim_audio([[i.start_time, i.end_time]], f"./denoised/{split_model}/{
|
569 |
print(f"正在合成第{i.index}条语音")
|
570 |
print(f"语音内容:{i.text.splitlines()[1]}")
|
571 |
predict(i.text.splitlines()[1], language, f"./sliced/sliced_audio_{i.index}_0.wav", i.text.splitlines()[1] + " " + str(i.index))
|
@@ -612,7 +615,7 @@ with gr.Blocks() as app:
|
|
612 |
|
613 |
btn.click(convert_from_srt, [inp1, inp2, inp3, inp4, inp5], [out1])
|
614 |
|
615 |
-
gr.Markdown("### <center
|
616 |
gr.HTML('''
|
617 |
<div class="footer">
|
618 |
<p>🌊🏞️🎶 - 江水东流急,滔滔无尽声。 明·顾璘
|
|
|
542 |
def convert_from_srt(filename, video_full, language, split_model, multilingual):
|
543 |
subtitle_list = read_srt(filename)
|
544 |
|
545 |
+
if os.path.exists("audio_full.wav"):
|
546 |
+
os.remove("audio_full.wav")
|
547 |
+
|
548 |
ffmpeg.input(video_full).output("audio_full.wav", ac=2, ar=44100).run()
|
549 |
|
550 |
if split_model=="UVR-HP2":
|
|
|
552 |
else:
|
553 |
pre_fun = pre_fun_hp5
|
554 |
|
555 |
+
pre_fun._path_audio_("audio_full.wav", f"./denoised/{split_model}/{video_full.name}/", f"./denoised/{split_model}/{video_full.name}/", "wav")
|
556 |
|
557 |
shutil.rmtree("output")
|
558 |
shutil.rmtree("sliced")
|
|
|
560 |
for i in subtitle_list:
|
561 |
os.makedirs("output", exist_ok=True)
|
562 |
os.makedirs("sliced", exist_ok=True)
|
563 |
+
trim_audio([[i.start_time, i.end_time]], f"./denoised/{split_model}/{video_full.name}/vocal_{video_full.name}.wav_10.wav", f"./sliced/sliced_audio_{i.index}")
|
564 |
print(f"正在合成第{i.index}条语音")
|
565 |
print(f"语音内容:{i.text}")
|
566 |
predict(i.text, language, f"./sliced/sliced_audio_{i.index}_0.wav", i.text + " " + str(i.index))
|
|
|
568 |
for i in subtitle_list:
|
569 |
os.makedirs("output", exist_ok=True)
|
570 |
os.makedirs("sliced", exist_ok=True)
|
571 |
+
trim_audio([[i.start_time, i.end_time]], f"./denoised/{split_model}/{video_full.name}/vocal_{video_full.name}.wav_10.wav", f"./sliced/sliced_audio_{i.index}")
|
572 |
print(f"正在合成第{i.index}条语音")
|
573 |
print(f"语音内容:{i.text.splitlines()[1]}")
|
574 |
predict(i.text.splitlines()[1], language, f"./sliced/sliced_audio_{i.index}_0.wav", i.text.splitlines()[1] + " " + str(i.index))
|
|
|
615 |
|
616 |
btn.click(convert_from_srt, [inp1, inp2, inp3, inp4, inp5], [out1])
|
617 |
|
618 |
+
gr.Markdown("### <center>注意❗:请勿生成会对任何个人或组织造成侵害的内容,请尊重他人的著作权和知识产权。用户对此程序的任何使用行为与程序开发者无关。</center>")
|
619 |
gr.HTML('''
|
620 |
<div class="footer">
|
621 |
<p>🌊🏞️🎶 - 江水东流急,滔滔无尽声。 明·顾璘
|