Skip to content

feat(speech_recognition): add faster-whisper engine backend - #543

Draft
jatinkrmalik wants to merge 9 commits into
mainfrom
feature/faster-whisper-engine
Draft

feat(speech_recognition): add faster-whisper engine backend#543
jatinkrmalik wants to merge 9 commits into
mainfrom
feature/faster-whisper-engine

Conversation

@jatinkrmalik

@jatinkrmalik jatinkrmalik commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds faster-whisper as a new speech recognition engine for Vocalinux, delivering significantly faster CPU inference via CTranslate2 and INT8 quantization. It also lays the groundwork for future engine additions by introducing a minimal Engine Protocol and an engines/ registry.

https://huggingface.co/collections/Systran/faster-whisper

What changed

Phase 0 — engine abstraction

  • Added EngineType enum and Engine Protocol to src/vocalinux/common_types.py.
  • Added src/vocalinux/speech_recognition/engines/__init__.py as a registry for engine implementations.

Phase 1 — faster-whisper backend

  • New src/vocalinux/speech_recognition/engines/faster_whisper_engine.py implementing the Engine Protocol.
  • New src/vocalinux/utils/faster_whisper_model_info.py for model metadata, download-cache detection, and recommendations.
  • Wired the engine into SpeechRecognitionManager (init, transcribe, reconfigure, reinitialize-after-resume).
  • Added "faster_whisper" to CLI --engine choices.
  • Added engine/model entries to the Settings UI and ConfigManager defaults.
  • Added faster-whisper>=1.0.0 as an optional dependency ([faster_whisper]).
  • Added vocalinux.speech_recognition.engines to setuptools packages.
  • Added tests/test_faster_whisper_engine.py with 17 unit tests.
  • Updated tests/test_suspend_handler.py fixture for the new _faster_whisper_engine attribute.

How to try it

pip install "vocalinux[faster_whisper]"
python -m vocalinux.main --engine faster_whisper --model tiny

Verification

  • pytest tests/test_faster_whisper_engine.py — 17/17 passed.
  • Affected regression tests (config, settings, recognition manager init, suspend handler) — 179/179 passed.
  • make lint (black, isort, flake8) passed via pre-commit hooks.
  • Note: a handful of pre-existing IBus environment tests fail locally and are unrelated to this change.

Introduce a typed EngineType enum and an Engine Protocol in common_types.py,
plus an engines/ registry so new speech recognition backends can be plugged in
without scattering string comparisons across the manager.
Add a faster-whisper engine implementation using CTranslate2/INT8 for fast
CPU inference. Includes model metadata utility, wiring through the recognition
manager, CLI, settings UI, config, optional dependency, and unit tests. Also
updates the suspend-handler test fixture for the new engine attribute.
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file app Core Python application (src, packaging) tests Test suite changes labels Jul 18, 2026
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.87037% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.76%. Comparing base (3d65e5c) to head (0184b8e).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ocalinux/speech_recognition/recognition_manager.py 30.43% 26 Missing and 6 partials ⚠️
src/vocalinux/common_types.py 73.33% 4 Missing ⚠️
...peech_recognition/engines/faster_whisper_engine.py 98.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #543      +/-   ##
==========================================
- Coverage   84.83%   84.76%   -0.07%     
==========================================
  Files          33       36       +3     
  Lines        5861     6077     +216     
  Branches      951      979      +28     
==========================================
+ Hits         4972     5151     +179     
- Misses        688      719      +31     
- Partials      201      207       +6     
Files with missing lines Coverage Δ
src/vocalinux/main.py 91.47% <ø> (ø)
...c/vocalinux/speech_recognition/engines/__init__.py 100.00% <100.00%> (ø)
src/vocalinux/ui/config_manager.py 98.70% <ø> (ø)
src/vocalinux/utils/faster_whisper_model_info.py 100.00% <100.00%> (ø)
...peech_recognition/engines/faster_whisper_engine.py 98.55% <98.55%> (ø)
src/vocalinux/common_types.py 74.28% <73.33%> (-0.72%) ⬇️
...ocalinux/speech_recognition/recognition_manager.py 81.63% <30.43%> (-1.43%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Import missing get_compute_type helper

- Add tests for English-only detection, cache exceptions, and import-error registry path

- Clear _has_torch_cuda lru_cache around exception test to avoid cached True

- Replace broad builtins.__import__ patch with a fake engine module for registry test

- Restore registry module state after test
Cover previously missing lines in:

- faster_whisper_model_info.py: HF cache path/none, hf_hub lookup, fallback traversal, torch CUDA true, psutil exception

- faster_whisper_engine.py: model None guard after is_ready()

- engine registry import-error path
- Add faster_whisper to --engine help text and examples

- Add faster-whisper as interactive option 5 with description

- Install faster-whisper package and verify import at install time

- Add fallback to whisper.cpp if faster-whisper installation fails

- Add smoke test for faster-whisper import

- Update welcome message engine display name

- Note: faster-whisper models download automatically on first use
@github-actions github-actions Bot added the installer Install/uninstall scripts label Jul 18, 2026
@jatinkrmalik
jatinkrmalik marked this pull request as draft July 18, 2026 02:44
@jatinkrmalik jatinkrmalik self-assigned this Jul 18, 2026
- Inline FASTER_WHISPER_MODEL_INFO dict literal; drop unused AVAILABLE_MODELS/MODEL_SIZES

- Reuse _has_torch_cuda() in FasterWhisperEngine.device property

- Remove redundant model None guard after is_ready() verification

- Shrink faster-whisper default config in install.sh to engine + model_size

- Update device tests to manage _has_torch_cuda lru_cache

- Remove test for deleted dead-code guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Core Python application (src, packaging) dependencies Pull requests that update a dependency file installer Install/uninstall scripts tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant