Skip to main content

attribute_words

Function attribute_words 

Source
pub fn attribute_words(
    words: &[Word],
    turns: &[SpeakerTurn],
) -> Vec<WordAlignment>
Expand description

Attribute each ASR word to a diarization speaker turn, returning a WordAlignment per input word in the same order and length.

Equivalent to attribute_words_with_config with AttributionConfig::default.

Rules:

  • Overlap: the word goes to the turn with the greatest temporal overlap; speaker = turn.speaker. Confidence is scaled by the fraction of the word covered by that turn, so a word straddling two turns (or partly in silence) gets a lowered confidence while a fully-covered word keeps its ASR score.
  • No overlap: the word is attributed to the nearest turn by interval gap.
  • Empty turns: words pass through with speaker: None.

Ties (equal overlap, or equal gap) are broken deterministically by the smaller SpeakerId, then the earlier turn (lower original index).