Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime #116

Open
thewh1teagle opened this issue Jan 14, 2024 · 1 comment
Open

Realtime #116

thewh1teagle opened this issue Jan 14, 2024 · 1 comment

Comments

@thewh1teagle
Copy link
Contributor

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
Copy link

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));
    }

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

No branches or pull requests

2 participants