From 3168968cae4ce590daaf4263cb46aa23f979095c Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Tue, 28 Nov 2023 19:23:21 -0700 Subject: [PATCH] ok stream les go --- rust-whisper.d/src/main.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/rust-whisper.d/src/main.rs b/rust-whisper.d/src/main.rs index 0e4397f..70fc189 100644 --- a/rust-whisper.d/src/main.rs +++ b/rust-whisper.d/src/main.rs @@ -6,18 +6,23 @@ fn main() { std::env::var("P").unwrap_or(String::from("8")).parse::().expect("$P must be a number"), ).unwrap(); - 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"); - let audio_data = &whisper_rs::convert_integer_to_float_audio(&data16); + match std::env::var("WAV") { + Ok(wav) => { + let (header, data) = wav::read( + &mut std::fs::File::open(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"); + let audio_data = &whisper_rs::convert_integer_to_float_audio(&data16); - for _ in 0..3 { - let result = w.transcribe(&audio_data).unwrap(); - println!("{}", result); - } + let result = w.transcribe(&audio_data).unwrap(); + println!("{}", result); + }, + Err(_) => { + panic!("not impl stream"); + }, + }; } struct Whisper {