Eason Lu commited on
Commit
9e3f79b
·
1 Parent(s): 71667c2

avoid split english in translation text

Browse files

Former-commit-id: 4f07fba54f25dc645ed2998bfb24f0fc8060d04a

Files changed (1) hide show
  1. SRT.py +6 -0
SRT.py CHANGED
@@ -292,6 +292,12 @@ class SRT_script():
292
  else:
293
  trans_split_idx = len(translation) // 2
294
 
 
 
 
 
 
 
295
  # split the time duration based on text length
296
  time_split_ratio = trans_split_idx / (len(seg.translation) - 1)
297
 
 
292
  else:
293
  trans_split_idx = len(translation) // 2
294
 
295
+ # to avoid split English word
296
+ for i in range(trans_split_idx, len(translation)):
297
+ if not translation[i].encode('utf-8').isalpha():
298
+ trans_split_idx = i
299
+ break
300
+
301
  # split the time duration based on text length
302
  time_split_ratio = trans_split_idx / (len(seg.translation) - 1)
303