pub trait Embedder: Send + Sync {
// Required methods
fn dim(&self) -> usize;
fn embed(&self, audio: &[f32]) -> Result<Vec<f32>, EmbedderError>;
// Provided method
fn embed_batch(
&self,
audios: &[&[f32]],
) -> Result<Vec<Vec<f32>>, EmbedderError> { ... }
}Expand description
Speaker embedding extractor — turns a slice of 16 kHz mono audio into a fixed-dimension embedding vector. Implementations are expected to L2-normalize their output so cosine similarity is a meaningful metric downstream.
In v1.0 (M2) the polyvoice crate introduces Embedder as the canonical
trait. The legacy EmbeddingExtractor trait and its implementations
(FbankOnnxExtractor, OnnxEmbeddingExtractor, DummyExtractor) remain
available unchanged — M6 will deprecate them.
Required Methods§
Provided Methods§
Sourcefn embed_batch(&self, audios: &[&[f32]]) -> Result<Vec<Vec<f32>>, EmbedderError>
fn embed_batch(&self, audios: &[&[f32]]) -> Result<Vec<Vec<f32>>, EmbedderError>
Compute embeddings for a batch of audio segments. Default implementation is sequential; impls may override with a true batched ONNX call.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".