Fix speaker ID regex and page break/line spacing in transcript DOCX
This commit is contained in:
+4
-3
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user