Expose WhisperContextParameters and update examples

This commit is contained in:
Chris Raethke 2023-11-20 20:42:34 +10:00
parent bd197a36f3
commit 8d462f5dd3
5 changed files with 21 additions and 9 deletions

View file

@ -2,7 +2,7 @@
use hound::{SampleFormat, WavReader};
use std::path::Path;
use whisper_rs::{FullParams, SamplingStrategy, WhisperContext};
use whisper_rs::{FullParams, SamplingStrategy, WhisperContext, WhisperContextParameters};
fn parse_wav_file(path: &Path) -> Vec<i16> {
let reader = WavReader::open(path).expect("failed to read file");
@ -45,7 +45,10 @@ fn main() {
let original_samples = parse_wav_file(audio_path);
let samples = whisper_rs::convert_integer_to_float_audio(&original_samples);
let ctx = WhisperContext::new(&whisper_path.to_string_lossy()).expect("failed to open model");
let ctx = WhisperContext::new_with_params(
&whisper_path.to_string_lossy(),
WhisperContextParameters::default()
).expect("failed to open model");
let mut state = ctx.create_state().expect("failed to create key");
let mut params = FullParams::new(SamplingStrategy::default());
params.set_progress_callback_safe(|progress| println!("Progress callback: {}%", progress));