diff --git a/whisper-cpp-2023/rust.d/src/main.rs b/whisper-cpp-2023/rust.d/src/main.rs index a0e2e41..fb16b7c 100644 --- a/whisper-cpp-2023/rust.d/src/main.rs +++ b/whisper-cpp-2023/rust.d/src/main.rs @@ -1,7 +1,9 @@ use whisper_rs::{WhisperContext, FullParams, SamplingStrategy}; fn main() { - let mut ctx = WhisperContext::new("../models/ggml-tiny.en.bin").expect("failed to load model"); + let mut ctx = WhisperContext::new( + &std::env::var("MODEL").unwrap_or(String::from("../models/ggml-medium.en.bin")) + ).expect("failed to load model"); // create a params object let mut params = FullParams::new(SamplingStrategy::Greedy { best_of: 0 }); @@ -16,7 +18,9 @@ fn main() { // assume we have a buffer of audio data // here we'll make a fake one, floating point samples, 32 bit, 16KHz, mono //let audio_data = vec![0_f32; 16000 * 2]; - let (header, data) = wav::read(&mut std::fs::File::open("../git.d/samples/jfk.wav").expect("failed to open .wav")).expect("failed to decode .wav"); + let (header, data) = wav::read(&mut std::fs::File::open( + &std::env::var("WAV").unwrap_or(String::from("../git.d/samples/jfk.wav")) + ).expect("failed to open .wav")).expect("failed to decode .wav"); assert!(header.channel_count == 1); assert!(header.sampling_rate == 16000); let data16 = data.as_sixteen().expect("wav is not 32bit floats");