tazz4843 / whisper-rs

Rust bindings to https://github.com/ggerganov/whisper.cpp
The Unlicense
607 stars 105 forks source link

[Bug] can't use indicatif inside progress callback #114

Open thewh1teagle opened 5 months ago

thewh1teagle commented 5 months ago

When using indicatif in progress callback it crashes

use std::thread;
use std::time::Duration;

use indicatif::ProgressBar;

fn main() {
    let pb = ProgressBar::new(100);
    // setup whisper-rs model
    // tried with move or without
    // register progress callback
    params.set_progress_callback_safe(move |progress| {
        pb.set_position(progress);
    });
    pb.finish_with_message("done");
}
tazz4843 commented 5 months ago

Calling enable_steady_tick on the progress bar before doing anything more fixes it for this specific case. I'm tempted to remove set_progress_callback_safe until it can be rewritten after this issue since this is interesting.

thewh1teagle commented 5 months ago

I found this workround https://github.com/thewh1teagle/vibe/blob/main/core/src/model.rs#L58