Skip to main content

SpeechToTextModel

Trait SpeechToTextModel 

Source
pub trait SpeechToTextModel<B: Backend>: Send {
    // Required methods
    fn metadata(&self) -> &ModelMetadata;
    fn n_mels(&self) -> usize;
    fn encode_audio(&self, mel: Tensor<B, 3>) -> Result<Tensor<B, 3>>;
    fn decode_step(
        &self,
        tokens: &[u32],
        encoded: &Tensor<B, 3>,
    ) -> Result<Tensor<B, 1>>;
}
Expand description

Speech-to-text models (Whisper-style encoder–decoder). A separate contract from GenerativeModel: the encoder runs once per audio window, then the decoder is stepped over token prefixes against the fixed encoder states.

Required Methods§

Source

fn metadata(&self) -> &ModelMetadata

Architecture + hyperparameter metadata.

Source

fn n_mels(&self) -> usize

Mel bins the encoder expects (derived from its conv stem weights).

Source

fn encode_audio(&self, mel: Tensor<B, 3>) -> Result<Tensor<B, 3>>

Encodes one [1, n_mels, frames] log-mel window into encoder states [1, frames/2, hidden].

Source

fn decode_step( &self, tokens: &[u32], encoded: &Tensor<B, 3>, ) -> Result<Tensor<B, 1>>

Runs the decoder over the whole token prefix and returns the final position’s logits [vocab].

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§