refactor(diarization): expose first_appearance_order + build_name_map to crate (FR-SPK)

This commit is contained in:
iamdoubz
2026-07-14 00:04:56 -05:00
parent 51f5ff085c
commit fee18ebc59
+9 -4
View File
@@ -110,8 +110,9 @@ pub fn match_mic_speaker(
}
/// Distinct speaker labels in first-appearance order — spans come back from
/// the diarizer already sorted by start time.
fn first_appearance_order(spans: &[SpeakerSpan]) -> Vec<String> {
/// the diarizer already sorted by start time. `pub(crate)` so the Phase 3
/// per-stream path can reuse it to name its merged You + far-side spans.
pub(crate) fn first_appearance_order(spans: &[SpeakerSpan]) -> Vec<String> {
let mut seen = std::collections::HashSet::new();
spans
.iter()
@@ -152,8 +153,12 @@ fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
/// `mic_label` -> "You"; every other label, in first-appearance order ->
/// "Speaker 2", "Speaker 3", … (numbering starts at 2 — "You" stands in for
/// "Speaker 1" without ever being called that).
fn build_name_map(labels_in_order: &[String], mic_label: &str) -> HashMap<String, String> {
/// "Speaker 1" without ever being called that). `pub(crate)` so Phase 3 reuses
/// it for its merged You + far-side spans, keeping naming uniform app-wide.
pub(crate) fn build_name_map(
labels_in_order: &[String],
mic_label: &str,
) -> HashMap<String, String> {
let mut names = HashMap::new();
let mut next_speaker_number = 2;
for label in labels_in_order {