Whisper::State
Independent inference state for parallel transcription.
Multiple State instances can run inference concurrently on the same
model context. Each state maintains its own mel spectrogram, encoder
output, and decoder state.
whisper = Whisper.new("/path/to/model.bin")
state = whisper.create_state
# ... use state for inference ...
state.close
whisper.close
Instance methods
closed?
SourceRuns the decoder on the given token context in this state.
detected_language
Returns the detected language ID from the most recent transcription on this state.
Runs the encoder on the mel spectrogram in this state.
finalize
Sourcelang_auto_detect(offset_ms : Int32 = 0, n_threads : Int32 = 4) : Tuple(String, Hash(String, Float32))
Runs language auto-detection on this state's mel spectrogram.
Converts raw PCM audio to mel spectrogram in this state.
Sets a custom mel spectrogram in this state.
transcribe(samples : Array(Float32), language : String | Nil = "en", n_threads : Int32 = 4, translate : Bool = false, token_timestamps : Bool = false, tdrz_enable : Bool = false) : Array(Segment)
Runs full inference with this state on the given audio samples.
samples must be 32-bit float PCM audio normalized to [-1.0, 1.0], mono, at 16kHz.