Fix speaker rendered throughout paragraph

Each sentence or 'segment' in whisper would be preceded by a [speaker]
notation. This commit fixes that to only include the speaker in front
of a larger group (since a new speaker would start a new diarization
group this will always work).
This commit is contained in:
Marty Oehme 2023-08-23 15:13:04 +02:00
parent 13b5f22953
commit a79f825f66
Signed by: Marty
GPG Key ID: EDBF2ED917B2EF6A
1 changed files with 4 additions and 3 deletions

View File

@ -72,10 +72,11 @@ def output_txt(diarized_groups: list, transcription_path: Path) -> TxtTranscript
if captions:
speaker = g[0].split()[-1]
txt.append(f"[{speaker}] ")
for c in captions:
txt.append(f"[{speaker}] {c['text']}\n")
txt.append("\n")
txt.append(f"{c['text']}")
txt.append("\n\n")
output = "".join(txt)
fname = Path.joinpath(transcription_path, "transcription_result.txt")