Build extensions using Bazel
mainThe project uses bazel as its build system. You can use the provided tools/bazel script to build the extensions:
./tools/bazel run extensionsrepository·main·Indexed 43 days ago
https://github.com/aarnphm/whispercppHigh-performance Pybind11 bindings for whisper.cpp, providing efficient speech-to-text transcription in Python. It features a high-level Whisper class for loading models via from_pretrained() and performing transcription from NumPy arrays or WAV files, as well as a low-level api module for direct access to whisper.cpp structures like Context and Params.
The project uses bazel as its build system. You can use the provided tools/bazel script to build the extensions:
./tools/bazel run extensionsExecute tests located in the tests/ and examples/ directories using Bazel:
./tools/bazel test tests/... examples/...Install the necessary Python dependencies for this example using pip:
pip install -r requirements.txtFor local development or custom builds, first initialize the submodules. You can then build the wheel using either pypa/build or bazel, and install the resulting wheel.
# Initialize submodules
git submodule update --init --recursive
# Option 1: using pypa/build
python3 -m build -w
pip install dist/*.whl
# Option 2: using bazel
./tools/bazel build //:whispercpp_wheel
pip install $(./tools/bazel info bazel-bin)/*.whlUse the provided build_bento.py script to package the Whisper service into a Bento. You can use the --override flag to overwrite an existing Bento.
# Build the bento
python build_bento.py
# Build and override existing bento
python build_bento.py --overrideOnce the Bento is built, use the BentoML CLI to create a container image for the whispercpp_asr service.
bentoml containerize whispercpp_asrTo set up an adhoc development environment, install nix and enter a new shell using the following command:
nix-shellYou can install the prebuilt package using pip. For platforms without prebuilt wheels, a hermetic toolchain will be used during installation, which may take longer. Use the -vv flag to monitor progress.
To install the latest version directly from the GitHub repository, use the following command:
# Standard installation
pip install whispercpp
# Install latest version from source
pip install git+https://github.com/aarnphm/whispercpp.git -vvTo run the pyright Python type checker, use the Bazel wrapper script:
./tools/bazel run //:pyrightTo build the project locally, first initialize all submodules:
git submodule update --init --recursiveThen, you can build the wheel using one of two methods:
Option 1: Using pypa/build
python3 -m build -wOption 2: Using Bazel
./tools/bazel build //:whispercpp_wheelAfter building, install the resulting wheel:
Via pypa/build:
pip install dist/*.whlVia Bazel:
pip install $(./tools/bazel info bazel-bin)/*.whlgit submodule update --init --recursive
python3 -m build -w
pip install dist/*.whlThe most convenient way to run all formatters is via treefmt using nix-shell. Alternatively, you can run black, isort, and ruff manually.
nix-shell --command treefmtYou can install the whispercpp package using pip.
pip install whispercpp