Skip to main content

EmbeddingExtractor

Trait EmbeddingExtractor 

Source
pub trait EmbeddingExtractor: Send + Sync {
    // Required methods
    fn extract(
        &self,
        samples: &[f32],
        config: &DiarizationConfig,
    ) -> Result<Vec<f32>, EmbeddingError>;
    fn embedding_dim(&self) -> usize;
}
👎Deprecated since 0.7.0:

use the v1.0 Embedder trait in polyvoice::embedder

Expand description

Trait for speaker embedding extractors.

Implementors are expected to be thread-safe (either internally synchronized or cheaply clonable), so that they can be shared across concurrent diarizers.

use polyvoice::{EmbeddingExtractor, DummyExtractor, DiarizationConfig};
let extractor = DummyExtractor::new(256);
let config = DiarizationConfig::default();
let samples = vec![0.0f32; config.window_samples()];
let emb = extractor.extract(&samples, &config).unwrap();
assert_eq!(emb.len(), 256);

Required Methods§

Source

fn extract( &self, samples: &[f32], config: &DiarizationConfig, ) -> Result<Vec<f32>, EmbeddingError>

👎Deprecated since 0.7.0:

use the v1.0 Embedder trait in polyvoice::embedder

Extract an embedding from raw 16 kHz (or config.sample_rate) mono f32 samples.

The caller is responsible for ensuring the buffer length matches the model expectations (usually config.window_samples()). Implementations may pad or truncate, but should prefer returning an error when the input is unusable.

Source

fn embedding_dim(&self) -> usize

👎Deprecated since 0.7.0:

use the v1.0 Embedder trait in polyvoice::embedder

Dimensionality of the produced embedding vectors.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl EmbeddingExtractor for DummyExtractor

Source§

impl EmbeddingExtractor for FbankOnnxExtractor

Available on crate feature onnx only.
Source§

impl EmbeddingExtractor for OnnxEmbeddingExtractor

Available on crate feature onnx only.