up whisper-rs to 0.8.0

master
Bel LaPointe 2023-11-08 09:25:00 -07:00
parent 247edd2ced
commit 91c7791860
3 changed files with 11 additions and 9 deletions

View File

@ -261,20 +261,21 @@ dependencies = [
[[package]]
name = "whisper-rs"
version = "0.5.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7e1b9b003aa3285a0e4469219566266aa1d51ced1be38587251a4f713a1677"
checksum = "2c950fb18ad556b053ba615b88fd4d01ed6020be740c3371eb0fc4aec64a0639"
dependencies = [
"whisper-rs-sys",
]
[[package]]
name = "whisper-rs-sys"
version = "0.3.1"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97a389dc665c7354ba6b1982850d4ba05b862907e535708ebdec92cbd9c599e8"
checksum = "094a5bd86f6f52562bbc74c28f27cd80197e54656cfb7213cf4ba37b5246cc9e"
dependencies = [
"bindgen",
"cfg-if",
]
[[package]]

View File

@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
whisper-rs = "0.5"
whisper-rs = "0.8.0"
wav = "1"
tokio = "1.27"

View File

@ -1,9 +1,10 @@
use whisper_rs::{WhisperContext, FullParams, SamplingStrategy};
fn main() {
let mut ctx = WhisperContext::new(
let ctx = WhisperContext::new(
&std::env::var("MODEL").unwrap_or(String::from("../models/ggml-tiny.en.bin"))
).expect("failed to load model");
let mut state = ctx.create_state().expect("failed to create state");
// create a params object
let mut params = FullParams::new(SamplingStrategy::Greedy { best_of: 0 });
@ -25,12 +26,12 @@ fn main() {
let data16 = data.as_sixteen().expect("wav is not 32bit floats");
let audio_data = &whisper_rs::convert_integer_to_float_audio(&data16);
ctx.full(params, &audio_data[..])
state.full(params, &audio_data[..])
.expect("failed to run model");
let num_segments = ctx.full_n_segments();
let num_segments = state.full_n_segments().unwrap_or(0);
for i in 0..num_segments {
let segment = ctx.full_get_segment_text(i).expect("failed to get segment");
let segment = state.full_get_segment_text(i).expect("failed to get segment");
print!("{} ", segment);
}
println!("");