WhisperCpp.Native (whisper_cpp v0.2.0)

Copy Markdown View Source

Low-level Rustler bindings to whisper.cpp via the whisper-rs crate.

This module is private to the library. Use WhisperCpp for the public API. Stub names must match the Rust NIF symbols verbatim (Rustler verifies arity at module load time); user-friendly wrappers live below them.

Summary

Functions

Returns true once an abort handle has been signalled.

Signals an abort handle; in-flight transcribes observing it return early.

Reports the active runtime backends compiled into this NIF artefact.

Loads a GGUF/GGML whisper.cpp model file.

Returns loaded-model metadata.

Mints a fresh cooperative-cancellation handle.

Runs whisper.cpp on a buffer of PCM samples.

Functions

abort_handle_aborted?(handle)

@spec abort_handle_aborted?(reference()) :: boolean()

Returns true once an abort handle has been signalled.

abort_handle_signal(handle)

@spec abort_handle_signal(reference()) :: :ok

Signals an abort handle; in-flight transcribes observing it return early.

available_devices()

@spec available_devices() :: {:ok, map()} | {:error, map()}

Reports the active runtime backends compiled into this NIF artefact.

load_model(path, opts)

@spec load_model(String.t(), map()) :: {:ok, reference()} | {:error, map()}

Loads a GGUF/GGML whisper.cpp model file.

model_info(model)

@spec model_info(reference()) :: {:ok, map()} | {:error, map()}

Returns loaded-model metadata.

new_abort_handle()

@spec new_abort_handle() :: reference()

Mints a fresh cooperative-cancellation handle.

transcribe(model, samples_bin, opts, abort_handle, progress_pid)

@spec transcribe(reference(), binary(), map(), reference() | nil, pid() | nil) ::
  {:ok, map()} | {:error, map()}

Runs whisper.cpp on a buffer of PCM samples.

samples_bin is a binary of little-endian f32 mono samples at 16 kHz. abort_handle is either nil or an opaque resource minted by new_abort_handle/0; signalling it from another process cancels in-flight inference. progress_pid is nil or a pid that receives {:whisper_progress, percent} messages as work advances.