Spaces:
Sleeping
Sleeping
Merge pull request #19 from project-kxkg/jiaen/batch_output
Browse filesJiaen/batch output
Former-commit-id: d3f4de05a6facb45767b5eef1fdf6804e04fe29f
- pipeline.py +7 -4
pipeline.py
CHANGED
@@ -195,8 +195,10 @@ if os.path.exists(zh_file):
|
|
195 |
pass
|
196 |
count += 1
|
197 |
segidx = int(count/4)+1
|
198 |
-
|
199 |
-
|
|
|
|
|
200 |
x = f1.readlines()
|
201 |
#print(len(x))
|
202 |
if count >= len(x):
|
@@ -260,9 +262,10 @@ for sentence, range in tqdm(zip(script_arr, range_arr)):
|
|
260 |
flag = True
|
261 |
# add read-time output back and modify the post-processing by using one batch as an unit.
|
262 |
srt.set_translation(translate, range, model_name)
|
263 |
-
|
|
|
264 |
srt.realtime_write_srt(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt",range, add_length,segidx)
|
265 |
-
srt.realtime_bilingual_write_srt(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_bi.srt",range, add_length,segidx)
|
266 |
|
267 |
# srt.check_len_and_split()
|
268 |
# srt.write_srt_file_translate(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt")
|
|
|
195 |
pass
|
196 |
count += 1
|
197 |
segidx = int(count/4)+1
|
198 |
+
en_file = "{}/{}/{}_en.srt".format(RESULT_PATH, VIDEO_NAME, VIDEO_NAME)
|
199 |
+
if args.srt_file is not None:
|
200 |
+
en_file = args.srt_file
|
201 |
+
with open(en_file, "r") as f1, open(temp_file, "a") as f2:
|
202 |
x = f1.readlines()
|
203 |
#print(len(x))
|
204 |
if count >= len(x):
|
|
|
262 |
flag = True
|
263 |
# add read-time output back and modify the post-processing by using one batch as an unit.
|
264 |
srt.set_translation(translate, range, model_name)
|
265 |
+
|
266 |
+
add_length = srt.check_len_and_split_range(range, threshold)
|
267 |
srt.realtime_write_srt(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt",range, add_length,segidx)
|
268 |
+
# srt.realtime_bilingual_write_srt(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_bi.srt",range, add_length,segidx)
|
269 |
|
270 |
# srt.check_len_and_split()
|
271 |
# srt.write_srt_file_translate(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt")
|