mirror of
https://github.com/m-bain/whisperX.git
synced 2025-07-01 18:17:27 -04:00
feat: include speaker information in WriteTXT when diarizing
This commit is contained in:
@ -214,7 +214,12 @@ class WriteTXT(ResultWriter):
|
|||||||
|
|
||||||
def write_result(self, result: dict, file: TextIO, options: dict):
|
def write_result(self, result: dict, file: TextIO, options: dict):
|
||||||
for segment in result["segments"]:
|
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):
|
class SubtitlesWriter(ResultWriter):
|
||||||
|
Reference in New Issue
Block a user