Skip to main content

A simple Python wrapper for whisper.cpp

Project description

Simpler Whisper

Build and Test

A zero-dependency simple Python wrapper for whisper.cpp, providing an easy-to-use interface for speech recognition using the Whisper model.

Why is it better than faster-whisper and pywhispercpp:

  • Zero-dependency: Everything is shipped with the built wheel, no Python dependency (on av or ctranslate2 etc.) except for numpy.
  • Dead simple API: call .transcribe() and get a result
  • Acceleration enabled: supports whatever whisper.cpp supports
  • Updated: using precompiled whisper.cpp from https://github.com/locaal-ai/occ-ai-dep-whispercpp
  • Build time: builds in 2 minutes because it's using a precompiled binary

Installation

To install simpler-whisper, you need:

  • A C++ compiler (e.g., GCC, Clang, or MSVC)
  • CMake (version 3.12 or higher)
  • NumPy

Then you can install using pip:

pip install simpler-whisper

Usage

import simpler_whisper.whisper
import numpy as np

# Load the model file.
# It's on you to download one from https://huggingface.co/ggerganov/whisper.cpp
model = simpler_whisper.whisper.load_model("path/to/model.bin")

# Load your 16kHz mono audio samples as a numpy array of float32
# It's on you if you need to convert (use av) or resample (use resampy)
audio = np.frombuffer(open("path/to/audio.raw", "rb").read(), dtype=np.float32)

# Transcribe
transcription = model.transcribe(audio)

print(transcription)

Platform-specific notes

  • On Windows, the package uses a DLL (whisper.dll), which is included in the package.
  • On Mac and Linux, the package uses static libraries that are linked into the extension.

Building from source

If you're building from source:

  1. Clone the repository:
    git clone https://github.com/locaal-ai/simpler-whisper.git
    cd simpler-whisper
    
  2. Install the package in editable mode:
    pip install -e .
    

This will run the CMake build process and compile the extension.

Build Configuration

Simpler Whisper supports various build configurations to optimize for different hardware and acceleration methods. You can specify the build configuration using environment variables:

  • SIMPLER_WHISPER_ACCELERATION: Specifies the acceleration method. Options are:
    • cpu (default)
    • cuda (for NVIDIA GPUs)
    • hipblas (for AMD GPUs)
    • vulkan (for cross-platform GPU acceleration)

Example: Building for Windows with CUDA acceleration

$env:SIMPLER_WHISPER_ACCELERATION="cuda"
pip install .

Example: Building for macOS ARM64

pip install .

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

simpler_whisper-0.2.4.post1-cp312-cp312-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.12Windows x86-64

simpler_whisper-0.2.4.post1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

simpler_whisper-0.2.4.post1-cp312-cp312-macosx_10_13_universal2.whl (4.2 MB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

simpler_whisper-0.2.4.post1-cp311-cp311-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.11Windows x86-64

simpler_whisper-0.2.4.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

simpler_whisper-0.2.4.post1-cp311-cp311-macosx_10_13_universal2.whl (2.8 MB view details)

Uploaded CPython 3.11macOS 10.13+ universal2 (ARM64, x86-64)

simpler_whisper-0.2.4.post1-cp310-cp310-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.10Windows x86-64

simpler_whisper-0.2.4.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (734.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

simpler_whisper-0.2.4.post1-cp310-cp310-macosx_10_13_universal2.whl (1.4 MB view details)

Uploaded CPython 3.10macOS 10.13+ universal2 (ARM64, x86-64)

File details

Details for the file simpler_whisper-0.2.4.post1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 039898ecfa5ce6ebffcbf829080b551c7634d5f9169fffd984b59c98d546c7be
MD5 82d04ef56980b34cc0c35b553bf56343
BLAKE2b-256 0d83a94be9f6b4ebde0bfe52acc9813c00a0278c5a194d784394a7b61aea2bd4

See more details on using hashes here.

File details

Details for the file simpler_whisper-0.2.4.post1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac8bb636c2985d8e5e8b330cafdd56c80065c996d9f02480e3484efae71ba37d
MD5 80664c41c8faa3b1f3b99a8e75029b6d
BLAKE2b-256 35668560ba1ca3380b6b6a3f3809175b07b916db36e843b063071f064c996786

See more details on using hashes here.

File details

Details for the file simpler_whisper-0.2.4.post1-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 1b9b78cc885879ecc3b521f94596704154840612b5e15b884dd82a8a4b8811aa
MD5 aba40db2c91a36a23ab49016eaa6a0de
BLAKE2b-256 c51bfba333f3271775a0501f279f79aa8bb2d88bcc3f3086f5d85ed25416c4bc

See more details on using hashes here.

File details

Details for the file simpler_whisper-0.2.4.post1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a820560eef729c08f983ac468fdd9d458e02c6942a20c767adc2581a4f54ed38
MD5 fd4f3f328496d859423917ad0a65e745
BLAKE2b-256 3358b0ae5451a32080be231b590972ed01fee6ab166beceba33628437639c17a

See more details on using hashes here.

File details

Details for the file simpler_whisper-0.2.4.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ddc8b16f3fa5e3a843724a405049600e6aa2757831095becda09d17b2f89b95c
MD5 b1738ee382670b5f5a282646c064392f
BLAKE2b-256 eda83ca26f99e85658c64e4957de9315ba42c8cd85f5eb35db7939dbb48e55b3

See more details on using hashes here.

File details

Details for the file simpler_whisper-0.2.4.post1-cp311-cp311-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp311-cp311-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 4d8d193122ad17b38f719bc9b4124ebdbe23e0cca681f977c06fcd271558607f
MD5 883b1c8228b2a139df12c37267a9855b
BLAKE2b-256 b308f994a07c1951015fae8f8cf89cc46824c36657d568b404807c59054657f1

See more details on using hashes here.

File details

Details for the file simpler_whisper-0.2.4.post1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b42cc736cc993f014e190f193b384701ec7f3bc6a7bed3993eedcd3edaeede3f
MD5 fde9f0061ba458a1e6dc7de0f001ebdd
BLAKE2b-256 afe6d14a68b3a9edc544a6fe5f49a89c304169cac74ed8c6fbc81fef1b4e22d5

See more details on using hashes here.

File details

Details for the file simpler_whisper-0.2.4.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85eaa44814e60e8ff6b838408c6fdb1a95e5ec71c5e2e5ccc9fff8f7b798a23a
MD5 17c10c554298f8a59420dca081a3b270
BLAKE2b-256 141706e0316b85ebe1a31a27495960cb77999614510eafbc7b81ee81616dbc3c

See more details on using hashes here.

File details

Details for the file simpler_whisper-0.2.4.post1-cp310-cp310-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post1-cp310-cp310-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 18c22454bb009f364979f2d893de8203b7513033b3f90eea6ff2c26d6481d4c2
MD5 822810de74e9f3a6a2da4e3601d69df4
BLAKE2b-256 57ef5ac6098bf97f1b1f7ec83faa736779170fa00f9bde07302bcad22217efce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page