pub struct WhisperModelWrapper { /* private fields */ }Implementations§
Source§impl WhisperModelWrapper
impl WhisperModelWrapper
Sourcepub fn new(
vb: VarBuilder<'_>,
config: Config,
mel_filters: Vec<f32>,
device: CandleDevice,
dtype: DType,
) -> Result<Self>
pub fn new( vb: VarBuilder<'_>, config: Config, mel_filters: Vec<f32>, device: CandleDevice, dtype: DType, ) -> Result<Self>
Load from VarBuilder + config.
Sourcepub fn from_model_dir(
model_dir: &Path,
device: CandleDevice,
dtype: DType,
) -> Result<Self>
pub fn from_model_dir( model_dir: &Path, device: CandleDevice, dtype: DType, ) -> Result<Self>
Load from model directory.
Sourcepub fn pcm_to_mel_tensor(&self, pcm: &[f32]) -> Result<Tensor>
pub fn pcm_to_mel_tensor(&self, pcm: &[f32]) -> Result<Tensor>
PCM → mel spectrogram tensor (matching Python whisper exactly). Pads or truncates PCM to exactly 30 seconds (N_SAMPLES = 480000).
Sourcepub fn encode(&self, mel: &Tensor) -> Result<Tensor>
pub fn encode(&self, mel: &Tensor) -> Result<Tensor>
Encode a mel segment → encoder hidden states.
Sourcepub fn decode_step(
&self,
tokens: &[u32],
encoder_out: &Tensor,
) -> Result<Vec<f32>>
pub fn decode_step( &self, tokens: &[u32], encoder_out: &Tensor, ) -> Result<Vec<f32>>
Run one decode pass: tokens → logits (includes KV cache, final_linear). On first call pass full initial_tokens; on subsequent calls pass only the new token.
Sourcepub fn reset_decoder(&self)
pub fn reset_decoder(&self)
Reset decoder KV cache (call between segments).
pub fn config(&self) -> &Config
pub fn device(&self) -> &CandleDevice
Auto Trait Implementations§
impl !Freeze for WhisperModelWrapper
impl !RefUnwindSafe for WhisperModelWrapper
impl !UnwindSafe for WhisperModelWrapper
impl Send for WhisperModelWrapper
impl Sync for WhisperModelWrapper
impl Unpin for WhisperModelWrapper
impl UnsafeUnpin for WhisperModelWrapper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more