fixed bug when only one speaker exists

This commit is contained in:
Jaikinator
2023-06-19 11:52:21 +02:00
parent 3ef7353db5
commit 7bfd294bbd
+18 -17
View File
@@ -54,29 +54,31 @@ class Diariser:
# This loop removes these duplicates # This loop removes these duplicates
### ###
if len(dia_list) == 1:
normalized_output.append([0, 0, dia_list[0]])
else:
for i, (_, _, speaker) in enumerate(dia_list): for i, (_, _, speaker) in enumerate(dia_list):
if i == 0:
current_speaker = speaker
if i == 0: if speaker != current_speaker:
current_speaker = speaker
if speaker != current_speaker: index_end_speaker = i - 1
index_end_speaker = i - 1 normalized_output.append([index_start_speaker,
index_end_speaker,
current_speaker])
normalized_output.append([index_start_speaker, index_start_speaker = i
index_end_speaker, current_speaker = speaker
current_speaker])
index_start_speaker = i if i == len(diarization_output["speakers"]) - 1:
current_speaker = speaker
if i == len(diarization_output["speakers"]) - 1: index_end_speaker = i
normalized_output.append([index_start_speaker,
index_end_speaker = i index_end_speaker,
normalized_output.append([index_start_speaker, current_speaker])
index_end_speaker,
current_speaker])
for outp in normalized_output: for outp in normalized_output:
start = dia_list[outp[0]][0].start start = dia_list[outp[0]][0].start
@@ -84,7 +86,6 @@ class Diariser:
diarization_output["segments"].append([start, end]) diarization_output["segments"].append([start, end])
diarization_output["speakers"].append(outp[2]) diarization_output["speakers"].append(outp[2])
return diarization_output return diarization_output
@staticmethod @staticmethod