Skip to content

whisper : run encoder_begin_callback on the language auto-detect path#3936

Open
javierdejesusda wants to merge 1 commit into
ggml-org:masterfrom
javierdejesusda:lang-detect-encoder-callback
Open

whisper : run encoder_begin_callback on the language auto-detect path#3936
javierdejesusda wants to merge 1 commit into
ggml-org:masterfrom
javierdejesusda:lang-detect-encoder-callback

Conversation

@javierdejesusda

Copy link
Copy Markdown

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.

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
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