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 Segment {
  Segment(
    text: String,
    start: Float,
    end: Float,
    words: List(Word),
  )
}

Constructors

  • Segment(
      text: String,
      start: Float,
      end: Float,
      words: List(Word),
    )
pub type Transcription {
  Transcription(
    text: String,
    segments: List(Segment),
    language: String,
    duration_s: Float,
  )
}

Constructors

  • Transcription(
      text: String,
      segments: List(Segment),
      language: String,
      duration_s: Float,
    )
pub type WhisperError {
  ModelLoadFailed(String)
  TranscribeFailed(String)
  DecodeFailed(String)
}

Constructors

  • ModelLoadFailed(String)
  • TranscribeFailed(String)
  • DecodeFailed(String)

Opaque 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.

✨ Search Document