Honor engine_options in the faster_whisper engine - #324
Open
TopGradeTech wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
faster_whisperadapter ignoresTranscriptionEngineConfig.engine_options, unlike theopenai_whisperandwhisper_cppadapters 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 intoWhisperModel(...)construction — e.g.cpu_threads,local_files_onlyengine_options["transcribe"]merges intomodel.transcribe(...), applied last so it overrides the mapped defaults — e.g.task,temperature19 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_optionsset is unchanged, covered by a dedicated regression test alongside tests for both merge paths.Rebased on current
master. This touches the sametranscribe()kwargs block as the batchedclip_timestampswork from the 1.0.3 release, so I kept that nested inside thebatch_sizebranch and applied the caller's options after it — your existingtest_batched_vad_disabled_supplies_full_audio_clip_timestampsstill passes.Tests
Documented in
docs/engines/faster-whisper.mdwith atask=translateexample.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.