whisper : run encoder_begin_callback on the language auto-detect path#3936
Open
javierdejesusda wants to merge 1 commit into
Open
whisper : run encoder_begin_callback on the language auto-detect path#3936javierdejesusda wants to merge 1 commit into
javierdejesusda wants to merge 1 commit into
Conversation
The language auto-detect path in whisper_full_with_state ran the encoder without firing encoder_begin_callback, unlike the main transcription loop. Callers that gate, observe, or abort whisper's encode through the callback had no control over the auto-detection pass. Guard the auto-detect encode with the callback the same way the main loop does. Fixes ggml-org#3888
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.
encoder_begin_callback is documented as a hook to abort before the encoder runs, but on the language auto-detection path it never gets consulted. When language is null/empty/"auto" or detect_language is set, whisper_full_with_state calls whisper_lang_auto_detect_with_state, which runs the encoder without ever checking the callback. So a caller that returns false to cancel gets ignored during auto-detect and the encode proceeds anyway.
This invokes encoder_begin_callback (when set) right before whisper_lang_auto_detect_with_state. If it returns false, we log and return -3, the same abort behavior already used for the encoder call later in the function. The non-auto-detect paths are unchanged.
Verified against current master that the auto-detect path previously reached the encoder with no callback consultation, and that the callback now fires first and aborts cleanly when it returns false. No automated test added since it is a small control-flow guard.