feat: limit speaker count to number of participants when specified #3510
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When participants are specified for a session, the number of speakers in the transcript should not exceed the number of participants. This PR modifies the segment builder to clamp
speaker_indexvalues from STT providers using modulo whennumSpeakersis specified.How it works: If
numSpeakersis 2 and the STT provider returnsspeaker_indexvalues of 0, 1, 2, 3, they get mapped to 0, 1, 0, 1 respectively (usingspeaker_index % numSpeakers).Files changed:
apps/desktop/src/utils/segment/index.ts- Added clamping logic increateSpeakerStateapps/desktop/src/utils/segment/segment.test.ts- Added 3 test cases for the new behaviorReview & Testing Checklist for Human
numSpeakers = 1to ensure all words are assigned to speaker 0.Notes
numSpeakersvalue comes fromuseSessionSpeakershook which returns the count of session participantsnumSpeakersis undefined or 0, the behavior is unchanged (no clamping)Requested by: @ComputelessComputer
Link to Devin run: https://app.devin.ai/sessions/f863e3124e784cf2bdd1f6d0ddf00982