MCPcopy Create free account
hub / github.com/absadiki/pywhispercpp / _encoder_begin_callback

Function _encoder_begin_callback

src/main.cpp:614–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612};
613
614bool _encoder_begin_callback(struct whisper_context * ctx, struct whisper_state * state, void * user_data){
615 (void) state;
616 struct whisper_context_wrapper ctx_w;
617 ctx_w.ptr = ctx;
618 auto * params = static_cast<WhisperFullParamsWrapper *>(user_data);
619 if (!params || !params->py_encoder_begin_callback) {
620 return false;
621 }
622
623 py::gil_scoped_acquire gil;
624 py::function callback = params->py_encoder_begin_callback;
625 py::object result_py;
626 if (!has_python_user_data(params->py_encoder_begin_callback_user_data)) {
627 result_py = callback(ctx_w);
628 } else {
629 result_py = callback(ctx_w, params->py_encoder_begin_callback_user_data);
630 }
631 bool res = result_py.cast<bool>();
632 return res;
633}
634
635void assign_encoder_begin_callback(struct whisper_full_params *params_base, py::object callback){
636 auto * params = static_cast<WhisperFullParamsWrapper *>(params_base);

Callers

nothing calls this directly

Calls 1

has_python_user_dataFunction · 0.85

Tested by

no test coverage detected