Realtime
thewh1teagle opened this issue · 1 comments
thewh1teagle commented
How should I show the transcibed words in realtime? I want to add this feature to vibe
Basiclly I need to register callback function for every chunk which transcribed and display it
So I'm wondering, if I use small batch size so user see the progress in small durations, will it affect the performance?
Anyway, I appreciate if you can tell me how to implement it or add some example for that, thanks!
bruceunx commented
I implement the following callback to stream realtime data. I checked your repo vibe
, It has some version conflict with whisper-rs
static mut COUNT: i32 = 0;
unsafe extern "C" fn callback(
_ctx: *mut whisper_rs_sys::whisper_context,
state: *mut whisper_rs_sys::whisper_state,
_progress: std::os::raw::c_int,
_user_data: *mut std::ffi::c_void,
) {
let num_segments = whisper_rs_sys::whisper_full_n_segments_from_state(state);
for i in COUNT..num_segments {
let ret = whisper_rs_sys::whisper_full_get_segment_text_from_state(state, i);
let c_str = CStr::from_ptr(ret);
let r_str = c_str.to_str().unwrap();
let t0 = whisper_rs_sys::whisper_full_get_segment_t0_from_state(state, i);
let t1 = whisper_rs_sys::whisper_full_get_segment_t1_from_state(state, i);
println!("[{} -> {}]: {}", t0, t1, r_str);
}
COUNT = num_segments;
}
unsafe {
params.set_progress_callback(Some(callback));
}