Skip to content

Commit

Permalink
feat: include speaker information in WriteTXT when diarizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Barabazs committed Jan 5, 2025
1 parent 9a8967f commit 26d9b46
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion whisperx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ class WriteTXT(ResultWriter):

def write_result(self, result: dict, file: TextIO, options: dict):
for segment in result["segments"]:
print(segment["text"].strip(), file=file, flush=True)
speaker = segment.get("speaker")
text = segment["text"].strip()
if speaker is not None:
print(f"[{speaker}]: {text}", file=file, flush=True)
else:
print(text, file=file, flush=True)


class SubtitlesWriter(ResultWriter):
Expand Down

0 comments on commit 26d9b46

Please sign in to comment.