Kaynağa Gözat

long vide fix

ming 3 yıl önce
ebeveyn
işleme
56713b011e
1 değiştirilmiş dosya ile 15 ekleme ve 12 silme
  1. 15 12
      OpenshotService/openshot_video_generator.py

+ 15 - 12
OpenshotService/openshot_video_generator.py

@@ -468,21 +468,24 @@ def adjustSub_by_text_similarity(gts_in,gens_raw):
     duplicated_list = []
     for idx in range(len(gens)):
         match_text = difflib.get_close_matches(gens[idx], alls, cutoff=0.1)
-        if match_text is not None:
-            if match_text[0] in duplicated_list:
-                for mt in match_text:
-                    if mt == adjusted[idx-1]: #or mt not in duplicated_list:
-                        adjusted[idx] = mt
-                        break
-            else:
+        if len(match_text) != 0:
+            if match_text[0] not in duplicated_list:
                 adjusted[idx] = match_text[0]
                 duplicated_list.append(match_text[0])
+            else:
+                if match_text[0] == adjusted[idx-1]:
+                    adjusted[idx] = match_text[0]
+                else:
+                    found = 0
+                    for mt in match_text:
+                        if mt not in duplicated_list:
+                            adjusted[idx] = mt
+                            found += 1
+                            break
+                    if found ==0:
+                        adjusted[idx] = ' '
         else :
-            adjusted[idx] = gens[idx]
-        
-        if None == adjusted[idx]:
-            adjusted[idx] = gens[idx]
-            
+            adjusted[idx] = ' '
 
     combine2_tag = [''.join([i,j]) for i,j in zip(gts_in, gts_in[1:])]
     combine3_tag = [''.join([i,j,k]) for i,j,k in zip(gts_in, gts_in[1:], gts_in[2:])]