Skip to content

whisper: add whisper_vad_set_context to set vad_context in the state#3617

Open
xlmod wants to merge 1 commit intoggml-org:masterfrom
xlmod:vad_set_context
Open

whisper: add whisper_vad_set_context to set vad_context in the state#3617
xlmod wants to merge 1 commit intoggml-org:masterfrom
xlmod:vad_set_context

Conversation

@xlmod
Copy link

@xlmod xlmod commented Jan 21, 2026

Add the ability to save a VAD context inside a state to prevent loading the VAD model multiple times when VAD is already used outside whisper_full, or when you want to load it with something other than the model_path.

Comment on lines +724 to +725
WHISPER_API void whisper_vad_set_context_to_state(struct whisper_state * state, struct whisper_vad_context * vctx);
WHISPER_API void whisper_vad_set_context (struct whisper_context * ctx, struct whisper_vad_context * vctx);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to:

Suggested change
WHISPER_API void whisper_vad_set_context_to_state(struct whisper_state * state, struct whisper_vad_context * vctx);
WHISPER_API void whisper_vad_set_context (struct whisper_context * ctx, struct whisper_vad_context * vctx);
WHISPER_API void whisper_state_set_vad(struct whisper_state * state, struct whisper_vad_context * vctx);
WHISPER_API void whisper_set_vad (struct whisper_context * ctx, struct whisper_vad_context * vctx);

src/whisper.cpp Outdated
int32_t exp_n_audio_ctx = 0; // 0 - use default

whisper_vad_context * vad_context = nullptr;
bool external_vad = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool external_vad = false;
bool vad_external = false;

 * whisper_vad_set_context set the vad_context of the current state and
   set external_vad to true.

 * whisper_vad_set_context_to_state set the vad_context of any state
   and set external_vad to true.

If a vad_context is set and external_vad is set to false then the
existing vad_context is set.

Co-authored-by: Thomas Guillem <thomas@gllm.fr>
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.

2 participants