fixed bug when only one speaker exists
This commit is contained in:
@@ -53,38 +53,39 @@ class Diariser:
|
|||||||
# Sometimes two consecutive speakers are the same
|
# Sometimes two consecutive speakers are the same
|
||||||
# This loop removes these duplicates
|
# This loop removes these duplicates
|
||||||
###
|
###
|
||||||
|
|
||||||
|
if len(dia_list) == 1:
|
||||||
for i, (_, _, speaker) in enumerate(dia_list):
|
normalized_output.append([0, 0, dia_list[0]])
|
||||||
|
else:
|
||||||
|
|
||||||
if i == 0:
|
for i, (_, _, speaker) in enumerate(dia_list):
|
||||||
current_speaker = speaker
|
if i == 0:
|
||||||
|
current_speaker = speaker
|
||||||
|
|
||||||
if speaker != current_speaker:
|
if speaker != current_speaker:
|
||||||
|
|
||||||
index_end_speaker = i - 1
|
index_end_speaker = i - 1
|
||||||
|
|
||||||
normalized_output.append([index_start_speaker,
|
normalized_output.append([index_start_speaker,
|
||||||
index_end_speaker,
|
index_end_speaker,
|
||||||
current_speaker])
|
current_speaker])
|
||||||
|
|
||||||
index_start_speaker = i
|
index_start_speaker = i
|
||||||
current_speaker = speaker
|
current_speaker = speaker
|
||||||
|
|
||||||
if i == len(diarization_output["speakers"]) - 1:
|
if i == len(diarization_output["speakers"]) - 1:
|
||||||
|
|
||||||
index_end_speaker = i
|
index_end_speaker = i
|
||||||
normalized_output.append([index_start_speaker,
|
normalized_output.append([index_start_speaker,
|
||||||
index_end_speaker,
|
index_end_speaker,
|
||||||
current_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
|
||||||
end = dia_list[outp[1]][0].end
|
end = dia_list[outp[1]][0].end
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user