From 4f44697ef05f15f50725828a19b03be6dcae612e Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Wed, 20 Dec 2023 09:33:57 -0500 Subject: [PATCH] just stream and wav --- rust-whisper-lib/src/lib.rs | 13 +++++-------- .../target/doc/rust_whisper_lib/all.html | 2 +- .../target/doc/rust_whisper_lib/fn.main.html | 2 -- .../target/doc/rust_whisper_lib/index.html | 2 +- .../target/doc/rust_whisper_lib/sidebar-items.js | 2 +- 5 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 rust-whisper-lib/target/doc/rust_whisper_lib/fn.main.html diff --git a/rust-whisper-lib/src/lib.rs b/rust-whisper-lib/src/lib.rs index 6d37f28..84bbebb 100644 --- a/rust-whisper-lib/src/lib.rs +++ b/rust-whisper-lib/src/lib.rs @@ -31,11 +31,7 @@ pub struct Flags { pub wav: Option, } -pub fn main(flags: Flags, handler_fn: F) where F: FnMut(Result) + Send + 'static { - main_wav(flags.clone(), handler_fn, flags.wav.unwrap()); -} - -pub fn main_wav(flags: Flags, handler_fn: F, wav_path: String) where F: FnMut(Result) + Send + 'static { +pub fn wav(flags: Flags, handler_fn: F, wav_path: String) where F: FnMut(Result) + Send + 'static { let w = new_service( flags.model_path, flags.model_buffer, @@ -55,7 +51,7 @@ pub fn main_wav(flags: Flags, handler_fn: F, wav_path: String) where F: FnMut w.transcribe(&audio_data); } -pub fn main_stream(flags: Flags, handler_fn: F, _stream: std::sync::mpsc::Receiver>) where F: FnMut(Result) + Send + 'static { +pub fn channel(flags: Flags, handler_fn: F, stream: std::sync::mpsc::Receiver>) where F: FnMut(Result) + Send + 'static { let w = new_service( flags.model_path, flags.model_buffer, @@ -72,7 +68,7 @@ pub fn main_stream(flags: Flags, handler_fn: F, _stream: std::sync::mpsc::Rec }; let mut buffer = vec![]; let mut last = Instant::now(); - for data in _stream.iter() { + for data in stream.iter() { data.iter().for_each(|x| buffer.push(*x)); if Instant::now() - last > stream_step { w.transcribe_async(&buffer).unwrap(); @@ -334,7 +330,7 @@ mod tests { #[test] fn test_transcribe_tiny_jfk_wav() { - main( + wav( Flags { model_path: None, model_buffer: Some(include_bytes!("../../models/ggml-tiny.en.bin").to_vec()), @@ -350,6 +346,7 @@ mod tests { assert!(result.is_ok()); assert_eq!(result.unwrap().to_string(), " And so my fellow Americans ask not what your country can do for you ask what you can do for your country."); }, + "../gitea-whisper-rs/sys/whisper.cpp/bindings/go/samples/jfk.wav".to_string(), ); } } diff --git a/rust-whisper-lib/target/doc/rust_whisper_lib/all.html b/rust-whisper-lib/target/doc/rust_whisper_lib/all.html index 97e2a45..180f87e 100644 --- a/rust-whisper-lib/target/doc/rust_whisper_lib/all.html +++ b/rust-whisper-lib/target/doc/rust_whisper_lib/all.html @@ -1 +1 @@ -List of all items in this crate

List of all items

Structs

Functions

\ No newline at end of file +List of all items in this crate

List of all items

Structs

Functions

\ No newline at end of file diff --git a/rust-whisper-lib/target/doc/rust_whisper_lib/fn.main.html b/rust-whisper-lib/target/doc/rust_whisper_lib/fn.main.html deleted file mode 100644 index eee7db7..0000000 --- a/rust-whisper-lib/target/doc/rust_whisper_lib/fn.main.html +++ /dev/null @@ -1,2 +0,0 @@ -main in rust_whisper_lib - Rust

Function rust_whisper_lib::main

source ·
pub fn main<F>(flags: Flags, handler_fn: F)where
-    F: FnMut(Result<Whispered, String>) + Send + 'static,
\ No newline at end of file diff --git a/rust-whisper-lib/target/doc/rust_whisper_lib/index.html b/rust-whisper-lib/target/doc/rust_whisper_lib/index.html index aff0935..2df602e 100644 --- a/rust-whisper-lib/target/doc/rust_whisper_lib/index.html +++ b/rust-whisper-lib/target/doc/rust_whisper_lib/index.html @@ -1 +1 @@ -rust_whisper_lib - Rust
\ No newline at end of file +rust_whisper_lib - Rust
\ No newline at end of file diff --git a/rust-whisper-lib/target/doc/rust_whisper_lib/sidebar-items.js b/rust-whisper-lib/target/doc/rust_whisper_lib/sidebar-items.js index 28f43de..a441077 100644 --- a/rust-whisper-lib/target/doc/rust_whisper_lib/sidebar-items.js +++ b/rust-whisper-lib/target/doc/rust_whisper_lib/sidebar-items.js @@ -1 +1 @@ -window.SIDEBAR_ITEMS = {"fn":["main"],"struct":["Flags","Whispered"]}; \ No newline at end of file +window.SIDEBAR_ITEMS = {"fn":["channel","wav"],"struct":["Flags","Transcribed"]}; \ No newline at end of file