소스 검색

去掉英文字幕

zhangyong 9 달 전
부모
커밋
88411b4a9e
2개의 변경된 파일6개의 추가작업 그리고 9개의 파일을 삭제
  1. 4 8
      common/gpt4o_help.py
  2. 2 1
      common/tts_help.py

+ 4 - 8
common/gpt4o_help.py

@@ -156,17 +156,13 @@ class GPT4o():
                     pw = match.group(1)
                     pw = match.group(1)
                     # 检查文本中是否包含英文字母
                     # 检查文本中是否包含英文字母
                     if re.search(r'[a-zA-Z]', pw):
                     if re.search(r'[a-zA-Z]', pw):
-                        cleaned_text = re.sub(r'[a-zA-Z]', '', pw)
+                        pw = re.sub(r'[a-zA-Z]', '', pw)
-                    else:
+                    return pw
-                        cleaned_text = pw
-                    return cleaned_text
                 else:
                 else:
                     if content:
                     if content:
                         if re.search(r'[a-zA-Z]', content):
                         if re.search(r'[a-zA-Z]', content):
-                            cleaned_text = re.sub(r'[a-zA-Z]', '', content)
+                            content = re.sub(r'[a-zA-Z]', '', content)
-                        else:
+                        return content
-                            cleaned_text = content
-                        return cleaned_text
                     if attempt == max_retries - 1:
                     if attempt == max_retries - 1:
                         return None
                         return None
             except Exception:
             except Exception:

+ 2 - 1
common/tts_help.py

@@ -132,7 +132,8 @@ class TTS:
             timecode_line = lines[i + 1].strip()
             timecode_line = lines[i + 1].strip()
             start_time, end_time = timecode_line.split(' --> ')
             start_time, end_time = timecode_line.split(' --> ')
             text = lines[i + 2].strip()
             text = lines[i + 2].strip()
-
+            if re.search(r'[a-zA-Z]', text):
+                text = re.sub(r'[a-zA-Z]', '', text)
             start_delta = cls.parse_timecode(start_time)
             start_delta = cls.parse_timecode(start_time)
             end_delta = cls.parse_timecode(end_time)
             end_delta = cls.parse_timecode(end_time)
             total_duration = (end_delta - start_delta).total_seconds()
             total_duration = (end_delta - start_delta).total_seconds()