rust-whisper-baked streams again woo

This commit is contained in:
Bel LaPointe
2023-12-20 09:48:38 -05:00
parent 1e56d44b2f
commit 3b6ae8801c
8 changed files with 32 additions and 1481 deletions

View File

@@ -563,6 +563,14 @@ version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
[[package]]
name = "listen-lib"
version = "0.1.0"
dependencies = [
"cpal",
"signal-hook",
]
[[package]]
name = "lock_api"
version = "0.4.11"
@@ -872,6 +880,7 @@ name = "rust-whisper-baked"
version = "0.1.0"
dependencies = [
"clap",
"listen-lib",
"rust-whisper-baked-lib",
"rust-whisper-lib",
]
@@ -890,8 +899,6 @@ dependencies = [
"byteorder",
"chrono",
"clap",
"cpal",
"signal-hook",
"tokio",
"wav",
"whisper-rs",

View File

@@ -8,4 +8,5 @@ edition = "2021"
[dependencies]
rust-whisper-lib = { path = "../rust-whisper-lib" }
rust-whisper-baked-lib = { path = "../rust-whisper-baked-lib" }
listen-lib = { path = "../listen-lib" }
clap = { version = "4.4.10", features = ["derive"] }

View File

@@ -1,16 +1,29 @@
use rust_whisper_lib;
use rust_whisper_baked_lib;
use clap::Parser;
use listen_lib;
use std::thread;
fn main() {
let flags = rust_whisper_lib::Flags::parse();
rust_whisper_baked_lib::main(
flags,
|result: Result<rust_whisper_lib::Whispered, String>| {
match result {
Ok(whispered) => { println!("{}", whispered.to_string()); },
Err(msg) => { eprintln!("error: {}", msg); },
};
},
);
let (send, recv) = std::sync::mpsc::sync_channel(100);
eprintln!("rust whisper baked lib channel...");
thread::spawn(move || {
rust_whisper_baked_lib::channel(
flags,
|result: Result<rust_whisper_lib::Transcribed, String>| {
match result {
Ok(transcribed) => { println!("{}", transcribed.to_string()); },
Err(msg) => { eprintln!("error: {}", msg); },
};
},
recv,
);
});
eprintln!("listen lib main...");
listen_lib::main(|data| {
send.send(data).unwrap();
});
}