浏览代码

去掉英文字幕

zhangyong 8 月之前
父节点
当前提交
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)
                     # 检查文本中是否包含英文字母
                     if re.search(r'[a-zA-Z]', pw):
-                        cleaned_text = re.sub(r'[a-zA-Z]', '', pw)
-                    else:
-                        cleaned_text = pw
-                    return cleaned_text
+                        pw = re.sub(r'[a-zA-Z]', '', pw)
+                    return pw
                 else:
                     if content:
                         if re.search(r'[a-zA-Z]', content):
-                            cleaned_text = re.sub(r'[a-zA-Z]', '', content)
-                        else:
-                            cleaned_text = content
-                        return cleaned_text
+                            content = re.sub(r'[a-zA-Z]', '', content)
+                        return content
                     if attempt == max_retries - 1:
                         return None
             except Exception:

+ 2 - 1
common/tts_help.py

@@ -132,7 +132,8 @@ class TTS:
             timecode_line = lines[i + 1].strip()
             start_time, end_time = timecode_line.split(' --> ')
             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)
             end_delta = cls.parse_timecode(end_time)
             total_duration = (end_delta - start_delta).total_seconds()