WhisperCt2.Native (whisper_ct2 v0.5.0)

Copy Markdown View Source

Low-level Rustler bindings to ct2rs::sys::Whisper.

This module is private to the library. Use WhisperCt2 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

CPU/CUDA device counts and the build's CUDA-support flag.

Loads a CT2 Whisper model directory.

Returns model metadata.

Runs Whisper on a buffer of PCM samples.

Runs Whisper on a list of PCM sample buffers in one batched generate call. Returns a list of structured transcription maps in input order.

Functions

available_devices()

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

CPU/CUDA device counts and the build's CUDA-support flag.

load_model(path, opts)

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

Loads a CT2 Whisper model directory.

model_info(model)

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

Returns model metadata.

transcribe(model, samples_bin, opts)

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

Runs Whisper on a buffer of PCM samples.

samples_bin is a binary of little-endian f32 samples (mono, 16 kHz). Audio longer than the 30 s Whisper window is chunked and batched internally; the encoder runs once across all chunks. Returns a structured transcription map (%{language, duration_s, segments: [...]}).

transcribe_batch(model, samples_bins, opts)

@spec transcribe_batch(reference(), [binary()], map()) ::
  {:ok, [map()]} | {:error, map()}

Runs Whisper on a list of PCM sample buffers in one batched generate call. Returns a list of structured transcription maps in input order.