diff --git a/src/whisper_params.rs b/src/whisper_params.rs index f0afb00..7e62c3b 100644 --- a/src/whisper_params.rs +++ b/src/whisper_params.rs @@ -1,6 +1,7 @@ use crate::whisper_grammar::WhisperGrammarElement; use std::ffi::{c_char, c_float, c_int, CString}; use std::marker::PhantomData; +use std::sync::Arc; use whisper_rs_sys::whisper_token; #[derive(Debug, Clone)] @@ -31,14 +32,15 @@ pub struct SegmentCallbackData { type SegmentCallbackFn = Box; +#[derive(Clone)] pub struct FullParams<'a, 'b> { pub(crate) fp: whisper_rs_sys::whisper_full_params, phantom_lang: PhantomData<&'a str>, phantom_tokens: PhantomData<&'b [c_int]>, grammar: Option>, - progess_callback_safe: Option>, - abort_callback_safe: Option bool>>, - segment_calllback_safe: Option, + progess_callback_safe: Option>>, + abort_callback_safe: Option bool>>>, + segment_calllback_safe: Option>, } impl<'a, 'b> FullParams<'a, 'b> { @@ -588,7 +590,7 @@ impl<'a, 'b> FullParams<'a, 'b> { self.fp.progress_callback = Some(trampoline::); self.fp.progress_callback_user_data = &mut closure as *mut F as *mut c_void; // store the closure internally to make sure that the pointer above remains valid - self.progess_callback_safe = Some(Box::new(closure)); + self.progess_callback_safe = Some(Arc::new(Box::new(closure))); } None => { self.fp.progress_callback = None;