Fix speaker ID regex and page break/line spacing in transcript DOCX
Mirror and run GitLab CI / build (push) Has been cancelled
Ruff / ruff (push) Has been cancelled

This commit is contained in:
admin
2026-06-20 18:47:07 +00:00
parent ffdabb6ae6
commit 92fce4e126
2 changed files with 35 additions and 14 deletions
+4 -3
View File
@@ -322,8 +322,8 @@ def _apply_speaker_map(transcript_text: str, segments: list, speaker_map: dict)
# Replace in transcript lines
def replace_in_line(line: str) -> str:
# Pattern: timestamp bracket + speaker label + colon
# More flexible: allow any non-empty label before the colon
# Match: [MM:SS] or [HH:MM:SS] then speaker label then colon
# Use a lazy match for the label up to the first colon
def repl(m):
prefix = m.group(1) # e.g. "[00:12] "
label = m.group(2).strip()
@@ -331,9 +331,10 @@ def _apply_speaker_map(transcript_text: str, segments: list, speaker_map: dict)
new_label = speaker_map.get(normalized, label)
return f"{prefix}{new_label}: "
return re.sub(
r"(\[\d+:\d+(?::\d+)?\]\s*)([^\]]+?):\s*",
r"(\[\d+:\d+(?::\d+)?\]\s*)(.+?):\s*",
repl,
line,
count=1,
)
updated_transcript = "\n".join(