whisper

Nim bindings for Whisper.cpp

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 1.1.1
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:26

Authors

  • Mark Leyva

Installation

nimble install whisper
choosenim install whisper
git clone https://github.com/maleyva1/whisper

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
whisper - - - - - - -

Dependencies

Package Version Optional
nim >= 2.0.0 No
wave >= 1.1.0 No
futhark >= 0.13.1 No

Source

Repository https://github.com/maleyva1/whisper
Homepage https://github.com/maleyva1/whisper
Registry Source nimble_official

README

Nim bindings for libwhisper

This package provides Nim bindings for libwhisper (1.5.0+) (AKA Whisper.cpp).

There are two major bindings:

  • simple bindings
  • higher level Nim wrapped bindings

The simple bindings expose the entirety of the libwhisper C API to Nim, while the higher level Nim wrapped bindings provide simpler but limited functionality.

Example

Using the high level bindings, we can run inference on a 16-bit WAV files, with the default libwhisper parameters. The high level bindings use Nim's lifetime tracking hooks, so users need don't need to manually free resources.

import whisper/highlevel

let 
    options = newDefaultOptions("ggml-base.en.bin")
    w = newWhisper(options)
    result = w.infer("samples/jfk.wav")

The equivalent using the simple bindings is more cumbersome, but is a one-to-one mapping of the C API.

import whisper/bindings

let file = "ggml-base.en.bin".cstring
var 
    params = whisperContextDefaultParams()
    ctx = whisperInitFromFileWithParams(file, params)
    fullParams = whisperFullDefaultParams(WHISPER_SAMPLING_GREEDY)
# Read 16-bit WAV file into bufffer (ptr cfloat)
# bufferLen contains the size of the buffer
whisperFull(ctx, fullParams, buffer, bufferLen)
whisperFree(ctx) # Free libwhisper context