Skip to content

Honor engine_options in the faster_whisper engine - #324

Open
TopGradeTech wants to merge 1 commit into
KoljaB:masterfrom
TopGradeTech:faster-whisper-engine-options
Open

Honor engine_options in the faster_whisper engine#324
TopGradeTech wants to merge 1 commit into
KoljaB:masterfrom
TopGradeTech:faster-whisper-engine-options

Conversation

@TopGradeTech

Copy link
Copy Markdown

The faster_whisper adapter ignores TranscriptionEngineConfig.engine_options, unlike the openai_whisper and whisper_cpp adapters which already honour it. That leaves no supported way to pass backend-specific options through to faster-whisper.

Change

Adopts the same option buckets the other adapters already use, so the behaviour is consistent across engines:

  • engine_options["model"] merges into WhisperModel(...) construction — e.g. cpu_threads, local_files_only
  • engine_options["transcribe"] merges into model.transcribe(...), applied last so it overrides the mapped defaults — e.g. task, temperature

19 lines in the adapter, plus docs and tests.

Relation to #114

Related but not a claimed fix. #114 asks why a hardcoded task="translate" didn't translate; this provides the supported route to pass that option rather than editing _transcription_worker. Worth noting for anyone arriving from that issue: Whisper's built-in translate task only ever outputs English, so it may not do what was wanted there regardless — which is a separate matter from the option not being passable at all.

Compatibility

Behaviour with no engine_options set is unchanged, covered by a dedicated regression test alongside tests for both merge paths.

Rebased on current master. This touches the same transcribe() kwargs block as the batched clip_timestamps work from the 1.0.3 release, so I kept that nested inside the batch_size branch and applied the caller's options after it — your existing test_batched_vad_disabled_supplies_full_audio_clip_timestamps still passes.

Tests

python -m unittest tests.unit.test_faster_whisper_engine -v
Ran 5 tests — OK

Documented in docs/engines/faster-whisper.md with a task=translate example.

Context

Found while building a local, offline captioning app on RealtimeSTT: it passes engine_options={"model": {"local_files_only": True}} to keep model loading offline. The argument is accepted and then silently ignored, so the app reached out to Hugging Face on every launch with nothing to indicate why — which is what led to this patch.

The faster_whisper adapter ignored TranscriptionEngineConfig.engine_options,
unlike the openai_whisper and whisper_cpp adapters, so backend-specific
options had no way through - notably task=translate for Whisper's
built-in speech translation (KoljaB#114), but also model options like
cpu_threads or transcribe options like temperature.

Adopt the same option buckets the other adapters already use:

- engine_options[model] merges into WhisperModel(...) construction
- engine_options[transcribe] merges into model.transcribe(...),
  overriding the mapped defaults

Behavior without engine_options is unchanged, covered by a new
regression test alongside tests for both merge paths. Documented in
docs/engines/faster-whisper.md with a task=translate example.
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.

1 participant