42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use rust_whisper_lib;
|
|
|
|
pub fn channel<F>(
|
|
mut flags: rust_whisper_lib::Flags,
|
|
handler_fn: F,
|
|
stream: std::sync::mpsc::Receiver<Vec<f32>>,
|
|
) where F: FnMut(Result<rust_whisper_lib::Transcribed, String>) + Send + 'static {
|
|
flags.model_path = None;
|
|
flags.model_buffer = Some(get_fast());
|
|
rust_whisper_lib::channel(flags.clone(), handler_fn, stream);
|
|
}
|
|
|
|
pub fn wav<F>(
|
|
mut flags: rust_whisper_lib::Flags,
|
|
handler_fn: F
|
|
) where F: FnMut(Result<rust_whisper_lib::Transcribed, String>) + Send + 'static {
|
|
flags.model_path = None;
|
|
flags.model_buffer = Some(get_good());
|
|
rust_whisper_lib::wav(flags.clone(), handler_fn, flags.wav.unwrap());
|
|
}
|
|
|
|
pub fn wav_channel<F>(
|
|
mut flags: rust_whisper_lib::Flags,
|
|
handler_fn: F
|
|
) where F: FnMut(Result<rust_whisper_lib::Transcribed, String>) + Send + 'static {
|
|
flags.model_path = None;
|
|
flags.model_buffer = Some(get_good());
|
|
rust_whisper_lib::wav_channel(flags, handler_fn);
|
|
}
|
|
|
|
pub fn f32_from_wav_file(path: &String) -> Result<Vec<f32>, String> {
|
|
rust_whisper_lib::f32_from_wav_file(path)
|
|
}
|
|
|
|
fn get_fast() -> Vec<u8> {
|
|
include_bytes!("../../models/ggml-small.en.bin").to_vec()
|
|
}
|
|
|
|
fn get_good() -> Vec<u8> {
|
|
include_bytes!("../../models/ggml-distil-medium.en.bin").to_vec()
|
|
}
|