Skip to content

feat: add whisper.cpp engine via CLI wrapper abstraction (and outline path to real-time whisper.cpp with VAD) - #19

Draft
sjjsy wants to merge 2 commits into
Oaklight:masterfrom
sjjsy:feature/whisper-cpp-engine
Draft

feat: add whisper.cpp engine via CLI wrapper abstraction (and outline path to real-time whisper.cpp with VAD)#19
sjjsy wants to merge 2 commits into
Oaklight:masterfrom
sjjsy:feature/whisper-cpp-engine

Conversation

@sjjsy

@sjjsy sjjsy commented May 16, 2026

Copy link
Copy Markdown

Summary

Implement a lightweight local speech-to-text alternative using whisper.cpp via a CLI wrapper:

  • Create asr2clip/engines/whisper_cpp.py implementing the BaseEngine interface (transcribe(), test(), and name).
  • Register the new engine in the create_engine() factory within engines/init.py.
  • Handle engine configuration parameters via standard definitions in config.py.
  • No breaking changes.

Provide the structural foundation for whisper.cpp based local transcription, with a clear architectural path forward toward non-blocking concurrent queuing (Producer-Consumer) in future iterations.

Finalization and test plan

  • Run proper testing on the whisper.cpp engine wrapper in a supported system.
  • Ensure ruff check passes cleanly before requesting final review.
  • Installation instructions could be provided by the tool whenever whisper.cpp setup seems lacking.
  • This whisper.cpp engine could be advertised in the project README.md.

Disclaimers

  • Draft: This is submitted as a Draft PR for early architectural visibility and feedback. This does not fully honor CONTRIBUTING.md yet especially because ...
  • Proper testing is not done: I am soon upgrading my test environment to match with the tool's requirements and will complete the checklist above and push necessary fixes before considering this work ready to be merged.
  • AI tools were used to assist with this work.

Future steps

This CLI wrapper design is simple and well suited for occasional and/or long transcription jobs. However, the asr2clip project describes itself as "Real-time speech-to-text clipboard tool with Silero VAD and local ASR support". We could evolve or extend this implementation to fulfill that description better: The whisper.cpp project includes a simple HTTP server that could perhaps provide non-blocking concurrent queuing (a Producer-Consumer model) as an alternative that would be better suited for rapidly processing successive transcription jobs (mimicking the sherpa-onnx design but with a leaner implementation for resource constrained systems):

  • Persistent Inference Server: While the CLI tool reloads a 0-5 GB model into RAM for every job separately, a persistent background server implementation could keep it ready, eliminating latency.
  • Threaded VAD Producer: A dedicated thread for continuous capture and Silero VAD segmentation to ensure zero "blind spots" during recording and submission of logical chunks for concurrent transcription.
  • Async Transcription Queue: A background consumer to pull audio segments and process them via local API concurrently for rapid throughput.
  • Context-Optimized Slicing: Tuning VAD thresholds (2-3s) to provide full sentence context, maximizing transformer accuracy and grammatical logic. Whisper.cpp also includes a "streaming" example but I feel it is not interesting for this project.
  • Automatic Start & Shutdown: In theory the asr2clip tool could itself launch the server with a limited lifespan when no server is available, and the server's lifetime could be extended by each job such that the server shuts itself down to free memory only when it has been idle for a while.

@Oaklight

Copy link
Copy Markdown
Owner

Hey Samuel,

Your whisper_cpp.py looks good — straightforward and well handled on the error paths.

I just reworked the engine config system on my side (named instances, multi-instance support, etc.), so the integration points here would need to be redone against the new layout. I'm planning to take your whisper_cpp.py, wire it up to the current architecture, and co-author the commit with your name. Holler if you have any concerns or want to tweak anything before I do that.

BTW I browsed through kaiku a bit — really liked how thorough the docs are. Picked up a few ideas from it.

@sjjsy

sjjsy commented May 17, 2026

Copy link
Copy Markdown
Author

Please go forward! And feel free to copy/adopt anything from kaiku -- even from the README if you like it (though linking is perhaps also an option)! Don't let me hold you down.

As I mentioned, this project was for me also a learning exercise and the kaiku README served as a place to document some of my learnings relating to ASR and related topics. Hopefully it serves someone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants