Update whisper.cpp

This commit is contained in:
Niko 2023-10-06 21:49:40 -06:00
parent f2d528e3c1
commit 4b45810dca
No known key found for this signature in database
GPG key ID: 3861E636EA1E0E2B
4 changed files with 36 additions and 1 deletions

View file

@ -24,3 +24,5 @@ pub type WhisperNewSegmentCallback = whisper_rs_sys::whisper_new_segment_callbac
pub type WhisperStartEncoderCallback = whisper_rs_sys::whisper_encoder_begin_callback;
pub type WhisperProgressCallback = whisper_rs_sys::whisper_progress_callback;
pub type WhisperLogitsFilterCallback = whisper_rs_sys::whisper_logits_filter_callback;
pub type WhisperAbortCallback = whisper_rs_sys::whisper_abort_callback;
pub type WhisperLogCallback = whisper_rs_sys::whisper_log_callback;

View file

@ -53,6 +53,14 @@ pub fn get_lang_str(id: i32) -> Option<&'static str> {
}
}
/// Callback to control logging output: default behaviour is to print to stderr.
///
/// # C++ equivalent
/// `void whisper_set_log_callback(whisper_log_callback callback);`
pub unsafe fn set_log_callback(callback: whisper_rs_sys::whisper_log_callback) {
unsafe { whisper_rs_sys::whisper_set_log_callback(callback) }
}
/// Print system information.
///
/// # C++ equivalent

View file

@ -504,6 +504,31 @@ impl<'a, 'b> FullParams<'a, 'b> {
) {
self.fp.logits_filter_callback_user_data = user_data;
}
/// Set the callback that is called each time before ggml computation starts.
///
/// Note that this callback has not been Rustified yet (and likely never will be, unless someone else feels the need to do so).
/// It is still a C callback.
///
/// # Safety
/// Do not use this function unless you know what you are doing.
/// * Be careful not to mutate the state of the whisper_context pointer returned in the callback.
/// This could cause undefined behavior, as this violates the thread-safety guarantees of the underlying C library.
///
/// Defaults to None.
pub unsafe fn set_abort_callback(&mut self, abort_callback: crate::WhisperAbortCallback) {
self.fp.abort_callback = abort_callback;
}
/// Set the user data to be passed to the abort callback.
///
/// # Safety
/// See the safety notes for `set_abort_callback`.
///
/// Defaults to None.
pub unsafe fn set_abort_callback_user_data(&mut self, user_data: *mut std::ffi::c_void) {
self.fp.abort_callback_user_data = user_data;
}
}
// following implementations are safe

@ -1 +1 @@
Subproject commit 54735be80f85fec2b08b09b44641b2698dbdef79
Subproject commit 91c0b23384fc3725013c4b6d3b35c45ad92dea0a