feat: bind whisper.cpp Parakeet API - #172
Conversation
Bump whisper.cpp to a master revision that includes Parakeet, link the parakeet library from CMake, add minimal pybind11 surface plus ParakeetModel, and cover bindings with unit tests that do not need a large model download. Refs absadiki#171
Drop unused aliases/helpers, reuse Model._load_audio, trim pybind docstrings and optional exports. Minimal surface unchanged: init/free/full/segments + thin ParakeetModel.
call_guard gil_scoped_release around the whole init wrapper meant py::cast ran without the GIL and SIGSEGV'd after a successful GGUF load. Release only during the C++ load, then construct the Python object.
|
Thanks so much @jatinkrmalik for the early draft! I really appreciate it. This looks like the direction I had in mind. Having a separate ParakeetModel while keeping a similar high-level Python interface makes sense, since Parakeet exposes its own native API (parakeet.h) I gave the PR a quick try locally, but it didn't work at first. I noticed that Parakeet support wasn't actually introduced until whisper.cpp v1.9.0, so we'll need to bump the submodule to at least that version. While looking into it, I realized the project could benefit from some refactoring to better support additional model architectures in the future. So I went ahead and implemented those changes on top of your work. Whenever you get a chance, could you try #173 on your end and let me know if everything works as expected? If it does, we can use that as the basis for getting Parakeet support merged. One small note: the old Model class is now deprecated, though it will continue to work for backward compatibility. Going forward, I'd recommend using the new WhisperModel class. I also switched the parameter handling to dataclasses, which provides much better IDE autocomplete, type checking, and overall usability. Feel free to take a look through the code, I think the new structure should be fairly straightforward, and it should make adding support for future model architectures much cleaner. |
Summary
Adds Python bindings for whisper.cpp's Parakeet API (
parakeet.h), which is a separate C surface from Whisper.What this does
whisper.cppsubmodule to080bbbe85230f624f0b52127f1ae1218247989f9(master after Parakeet landed; previously v1.8.4 /9386f239)._pywhispercppagainst theparakeetlibrary as well aswhisper.src/parakeet_bindings.cpp):parakeet_context_default_params/parakeet_init_from_file_with_params/parakeet_freeparakeet_full_default_params/parakeet_full(float32 PCM)parakeet_version,PARAKEET_SAMPLE_RATEParakeetModel(pywhispercpp/parakeet_model.py): load a local GGUF,transcribe()path or float32 mono 16 kHz PCM, returns the sameSegmentobjects as WhisperModel. Audio path loading reusesModel._load_audio. No automatic model download; models from ggml-org/parakeet-GGUF.Day-one scope matches the issue: load model, run audio, get text. Not every
parakeet-cliflag.Out of scope (follow-ups)
Test plan
tests/test_parakeet.py: defaults, version, free/None, import, missing path)Modeltests still pass in CI (needs model files / full package install)Closes #171