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.post2-cp312-cp312-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.12Windows x86-64

simpler_whisper-0.2.4.post2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (735.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

simpler_whisper-0.2.4.post2-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.post2-cp311-cp311-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.11Windows x86-64

simpler_whisper-0.2.4.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (735.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

simpler_whisper-0.2.4.post2-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.post2-cp310-cp310-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.10Windows x86-64

simpler_whisper-0.2.4.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (735.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

simpler_whisper-0.2.4.post2-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.post2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e808f41ac0130777d4c60a727fea67576a5641c79502aee86e6d957da43c6ba2
MD5 205f4836e037fdddbd7d8843bf8a1587
BLAKE2b-256 dfdc62427a0fd87daebdf6a78c47b8b2a9e8768667e16c081a2c83b071663f9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f07ea7971bb074eac6597690ed5a86d0042cb2b8ae42cad87fae0173388a72c6
MD5 ccbd198fadcb1bcda2dc8a942f385d4e
BLAKE2b-256 46cefb383a6808f9f6512e078211e099528ff50b85655a166f53ec4415345717

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 7ee90abd0bdd4497a893b9abf0b680eb2eea79a328e9bcf5a951a28a14654ef1
MD5 1eaab8b704804b5297d97ed6ed7b15b0
BLAKE2b-256 462735d548ca273aedffb368661728571d980d8bc3d9c1e220b5edc787fe03f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f46caf4ce4dce604b97def20a4ac454f6a9185b9e7b42996292a735d3a01745b
MD5 152a61e95a37e8533250917aa55d3ab9
BLAKE2b-256 d34d6496dad67ae30c1ae01c75f1b9b91b7a1ffbacd332f0d48f5dc6cdc32f7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54f84879607354830f769df1fb224bb2cc6e0d01950d8ed9d7447a41675ec8aa
MD5 40f9720051867a087f4ec83910ada7fe
BLAKE2b-256 9fa5f4d3ca3598d0f6114bb8b8a9a838d83c5d7382573a08c79ecb3a70aefd66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp311-cp311-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 915bc36572a7b9b81f5dc7abd086687e7502178ee20db4d93df89cc7343f181c
MD5 7c14b37efc6a69a0f429d35011b34091
BLAKE2b-256 28a8b25747bb4b5629ff4465fce1e199056d5c6990f30195e28e9b8d52d9ebf7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 69c44f9f0a1f2ec15199792cdcbc7954778a173020bf0803d40a15667460ba84
MD5 5274870398c8bd5e3ed04ac7a48df046
BLAKE2b-256 1f2c8d2178adbaaa42c69d44a6d8f9b3905564389dfa66853e57a53e2a5c654c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6547e8a9290a7b461689175127036bed7800d107dca19ecc5e67e89131d8d8cc
MD5 d4685a5ce08127db291a1fc2e0eb58b8
BLAKE2b-256 f1011a0e7650579457833507594b7c59145930a3d2eff5cec891ecefa96dd357

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpler_whisper-0.2.4.post2-cp310-cp310-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 6e001cd09acbbb64d97e37014d4d53a374e4ad8571193dc8d41ac1ad5fe1c951
MD5 08440b1736311745832d481336b2d141
BLAKE2b-256 3025137cd46c5bf01c3a4d2f320328fd5f1d5e3f3fb25f7540e1b41cc8ef3782

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