Fix: Speaker Label Ordering and Convert to 1-Based Indexing
Issue Description
The speaker diarization output currently produces unordered speaker segments and uses zero-based indexing for speaker labels. This results in poor readability and makes it difficult to follow the conversation flow. This issue focuses on ensuring chronological ordering of segments and converting speaker labels to a consistent 1-based sequential format.
Problem Statement
- Speaker segments are not ordered by
start_time, causing incorrect conversation flow - Speaker labels appear out of sequence (e.g.,
SPEAKER_04,SPEAKER_01,SPEAKER_03) - Speaker numbering starts from zero (
SPEAKER_00) instead of one - Inconsistency between segment labels and
speaker_durationsmapping - Output is confusing and not user-friendly
Proposed Solution
- Sort all diarization segments based on
start_time(ascending order) - Remap speaker labels to 1-based indexing
- Convert
SPEAKER_00 → SPEAKER_01 - Ensure sequential numbering (
SPEAKER_01, SPEAKER_02, ...)
- Convert
- Maintain a consistent mapping between original speaker IDs and new labels
- Update speaker labels in:
- Segment outputs
-
speaker_durationsdictionary
- Ensure formatting consistency across the entire response
Tasks
- Sort diarized segments by
start_time - Create a mapping from old speaker IDs → new sequential labels
- Replace speaker labels in all segments
- Update keys in
speaker_durationsaccordingly - Ensure no speaker label starts with
00 - Test with multiple inputs to verify correct ordering and labeling
Acceptance Criteria
- All segments are chronologically ordered
- Speaker labels start from SPEAKER_01
- Labels are sequential and consistent (no skipping or disorder)
- No occurrence of SPEAKER_00 in output
- speaker_durations matches updated speaker labels
- Output is clear, readable, and logically structured
Edited by Vemuri priya