JiaenLiu commited on
Commit
9518a49
1 Parent(s): e10f7f9

bugs fixed

Browse files

Former-commit-id: be62aca589877af3c96bd5a534feba24e88a46c5

Files changed (3) hide show
  1. .gitignore +2 -0
  2. SRT.py +16 -7
  3. pipeline.py +1 -1
.gitignore CHANGED
@@ -5,3 +5,5 @@
5
  test.py
6
  test.srt
7
  test.txt
 
 
 
5
  test.py
6
  test.srt
7
  test.txt
8
+ log_*.csv
9
+ log.csv
SRT.py CHANGED
@@ -111,7 +111,7 @@ class SRT_script():
111
 
112
 
113
 
114
- def set_translation(self, translate:str, id_range:tuple, model,vid_link=None):
115
  start_seg_id = id_range[0]
116
  end_seg_id = id_range[1]
117
 
@@ -159,12 +159,21 @@ class SRT_script():
159
  if len(lines) < (end_seg_id - start_seg_id + 1):
160
  print("Failed Solving unmatched lines, Manually parse needed")
161
 
162
- log_file = "log.csv"
163
- log_exist = os.path.exists(log_file)
164
- with open(log_file,"a") as log:
165
- if not log_exist:
166
- log.write("range_of_text,iterations_solving,solved,file_length,video_link")
167
- log.write(range+','+count+','+solved+','+len(self.segments)+','+vid_link)
 
 
 
 
 
 
 
 
 
168
 
169
  print(lines)
170
  #print(id_range)
 
111
 
112
 
113
 
114
+ def set_translation(self, translate:str, id_range:tuple, model, video_name, video_link=None):
115
  start_seg_id = id_range[0]
116
  end_seg_id = id_range[1]
117
 
 
159
  if len(lines) < (end_seg_id - start_seg_id + 1):
160
  print("Failed Solving unmatched lines, Manually parse needed")
161
 
162
+
163
+ if video_link:
164
+ log_file = "./logs/log_link.csv"
165
+ log_exist = os.path.exists(log_file)
166
+ with open(log_file,"a") as log:
167
+ if not log_exist:
168
+ log.write("range_of_text,iterations_solving,solved,file_length,video_link" + "\n")
169
+ log.write(str(id_range)+','+str(count)+','+str(solved)+','+str(len(self.segments))+','+video_link + "\n")
170
+ else:
171
+ log_file = "./logs/log_name.csv"
172
+ log_exist = os.path.exists(log_file)
173
+ with open(log_file,"a") as log:
174
+ if not log_exist:
175
+ log.write("range_of_text,iterations_solving,solved,file_length,video_name" + "\n")
176
+ log.write(str(id_range)+','+str(count)+','+str(solved)+','+str(len(self.segments))+','+video_name + "\n")
177
 
178
  print(lines)
179
  #print(id_range)
pipeline.py CHANGED
@@ -277,7 +277,7 @@ for sentence, range in tqdm(zip(script_arr, range_arr)):
277
  time.sleep(30)
278
  flag = True
279
  # add read-time output back and modify the post-processing by using one batch as an unit.
280
- srt.set_translation(translate, range, model_name)
281
 
282
  # srt.realtime_bilingual_write_srt(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_bi.srt",range, add_length,segidx)
283
 
 
277
  time.sleep(30)
278
  flag = True
279
  # add read-time output back and modify the post-processing by using one batch as an unit.
280
+ srt.set_translation(translate, range, model_name, VIDEO_NAME, args.link)
281
 
282
  # srt.realtime_bilingual_write_srt(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_bi.srt",range, add_length,segidx)
283