alignment/whisper_driver
whisper_cpp driver — BEAM interop for speech-to-text with word timestamps.
Wraps the Elixir WhisperCpp NIFs. Model handle is hidden behind an opaque WhisperModel type (wrapping dynamic.Dynamic internally). External callers can never touch the raw Elixir struct — this enforces the opaque-type pattern from custom-types.md.
Model caching: Erlang persistent_term, one ~500ms load per OTP session.
Types
pub type WhisperError {
ModelLoadFailed(String)
TranscribeFailed(String)
DecodeFailed(String)
}
Constructors
-
ModelLoadFailed(String) -
TranscribeFailed(String) -
DecodeFailed(String)
WhisperModel
opaqueOpaque handle to a loaded whisper model. Internally wraps the Elixir struct that whisper_cpp.load_model returns. External modules can’t construct or inspect — only pass back to us.
pub opaque type WhisperModel
pub type WhisperOpts {
WhisperOpts(
language: String,
word_timestamps: Bool,
beam_size: Int,
n_threads: Int,
initial_prompt: option.Option(String),
)
}
Constructors
-
WhisperOpts( language: String, word_timestamps: Bool, beam_size: Int, n_threads: Int, initial_prompt: option.Option(String), )
pub type Word {
Word(
text: String,
start: Float,
end: Float,
probability: Float,
)
}
Constructors
-
Word(text: String, start: Float, end: Float, probability: Float)
Values
pub fn default_model_path() -> String
pub fn default_opts() -> WhisperOpts
pub fn transcribe_pcm(
pcm: BitArray,
opts: WhisperOpts,
) -> Result(Transcription, WhisperError)
Transcribe PCM audio and return structured result with word timestamps.