Skip to main content

Clusterer

Trait Clusterer 

Source
pub trait Clusterer: Send + Sync {
    // Required methods
    fn cluster(
        &self,
        embeddings: &[Vec<f32>],
    ) -> Result<Vec<usize>, ClustererError>;
    fn max_clusters(&self) -> usize;
}
Expand description

Speaker clusterer — turns a batch of L2-normalized speaker embeddings into per-embedding cluster labels in the range 0..K where K is the inferred number of clusters.

In v1.0 (M3) the polyvoice crate introduces Clusterer as the canonical trait. The legacy free functions ahc::agglomerative_cluster_auto and spectral::spectral_cluster remain available — M6 will deprecate them.

Required Methods§

Source

fn cluster(&self, embeddings: &[Vec<f32>]) -> Result<Vec<usize>, ClustererError>

Cluster embeddings. Each inner vector must have the same length and be approximately L2-normalized.

Requires: embeddings.len() >= 1. Guarantees on Ok: result.len() == embeddings.len(), result[i] < unique(result).count() (compact 0..K numbering).

Source

fn max_clusters(&self) -> usize

Hard ceiling on the number of clusters this implementation can produce.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Clusterer for AhcClusterer

Source§

impl Clusterer for KMeansClusterer

Source§

impl Clusterer for NmeScClusterer

Available on crate feature spectral only.