A Python wrapper for whisper.cpp
Project description
whisper-cpp-python
whisper-cpp-python is a Python module inspired by llama-cpp-python that provides a Python interface to the whisper.cpp model. This module automatically parses the C++ header file of the project during building time, generating the corresponding Python bindings.
Installation
To install the module, you can use pip:
pip install whisper-cpp-python
Usage
To use the module, you need to create an instance of the Whisper
class, passing the path to the model file as a parameter. Then, you can call the transcribe
method to transcribe a given audio file.
from whisper_cpp_python import Whisper
model = Whisper('vendor/whisper.cpp/models/ggml-tiny.bin')
print(model.transcribe('vendor/whisper.cpp/samples/jfk.wav'))
In the example above, the module transcribes the jfk.wav
audio file using the ggml-tiny
model.
All interfaces provided by whisper.h
are available in python. The following example
show how to pass a custom progress_callback function to the model.
from whisper_cpp_python import Whisper
from whisper_cpp_python.whisper_cpp import whisper_progress_callback
def callback(ctx, state, i, p):
print(i)
model = Whisper('../quantized_models/whisper/models/ggml-tiny.bin')
model.params.progress_callback = whisper_progress_callback(callback)
print(model.transcribe('vendor/whisper.cpp/samples/jfk.wav'))
License
whisper-cpp-python is released under the MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for whisper_cpp_python-0.1.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 200173abc766ba17a2e531f8b69660f8f77dc73fba8309042fd933c32deed9bd |
|
MD5 | 410a280dd96c5c0aba8ab90d5bda4ed4 |
|
BLAKE2b-256 | c41c3b14af777e5828df7340ab71d5e6e08f2c2667246a21881e1107b7e1cba2 |