From 813a433a52006514ef63c6ed254439b152125fc5 Mon Sep 17 00:00:00 2001 From: arizhih Date: Tue, 23 Apr 2024 16:54:23 +0200 Subject: [PATCH] Update whisper.cpp version to 1.5.5 --- Cargo.toml | 4 ++-- src/lib.rs | 2 +- src/standalone.rs | 4 ++-- src/whisper_ctx.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++++ sys/Cargo.toml | 2 +- sys/build.rs | 2 +- sys/whisper.cpp | 2 +- 7 files changed, 59 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ce9adba..8b8c8fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ exclude = ["examples/full_usage"] [package] name = "whisper-rs" -version = "0.11.0" +version = "0.12.0" edition = "2021" description = "Rust bindings for whisper.cpp" license = "Unlicense" @@ -14,7 +14,7 @@ repository = "https://github.com/tazz4843/whisper-rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -whisper-rs-sys = { path = "sys", version = "0.8" } +whisper-rs-sys = { path = "sys", version = "0.10.0" } log = { version = "0.4", optional = true } tracing = { version = "0.1", optional = true } diff --git a/src/lib.rs b/src/lib.rs index a6da664..736eceb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,5 +42,5 @@ pub type WhisperNewSegmentCallback = whisper_rs_sys::whisper_new_segment_callbac pub type WhisperStartEncoderCallback = whisper_rs_sys::whisper_encoder_begin_callback; pub type WhisperProgressCallback = whisper_rs_sys::whisper_progress_callback; pub type WhisperLogitsFilterCallback = whisper_rs_sys::whisper_logits_filter_callback; -pub type WhisperAbortCallback = whisper_rs_sys::whisper_abort_callback; +pub type WhisperAbortCallback = whisper_rs_sys::ggml_abort_callback; pub type WhisperLogCallback = whisper_rs_sys::ggml_log_callback; diff --git a/src/standalone.rs b/src/standalone.rs index eb49751..8179943 100644 --- a/src/standalone.rs +++ b/src/standalone.rs @@ -105,7 +105,7 @@ pub struct SystemInfo { pub f16c: bool, pub blas: bool, pub clblast: bool, - pub cublas: bool, + pub cuda: bool, } impl Default for SystemInfo { @@ -118,7 +118,7 @@ impl Default for SystemInfo { f16c: whisper_rs_sys::ggml_cpu_has_f16c() != 0, blas: whisper_rs_sys::ggml_cpu_has_blas() != 0, clblast: whisper_rs_sys::ggml_cpu_has_clblast() != 0, - cublas: whisper_rs_sys::ggml_cpu_has_cublas() != 0, + cuda: whisper_rs_sys::ggml_cpu_has_cuda() != 0, } } } diff --git a/src/whisper_ctx.rs b/src/whisper_ctx.rs index 8d948cd..1f28d8e 100644 --- a/src/whisper_ctx.rs +++ b/src/whisper_ctx.rs @@ -552,6 +552,21 @@ pub struct WhisperContextParameters { /// **Warning**: Does not have an effect if OpenCL is selected as GPU backend /// (in that case, GPU is always enabled). pub use_gpu: bool, + /// GPU device id, default 0 + pub gpu_device: c_int, + /// [EXPERIMENTAL] Enable Token-level timestamps with DTW, default 0 + pub dtw_token_timestamps: bool, + /// Preset id for DTW, default whisper_alignment_heads_preset_WHISPER_AHEADS_NONE + pub dtw_aheads_preset : whisper_rs_sys::whisper_alignment_heads_preset, + /// Number of top text layers used from model. Only with whisper_alignment_heads_preset_WHISPER_AHEADS_N_TOP_MOST preset. + pub dtw_n_top : c_int, + /// Custom aheads, only with whisper_alignment_heads_preset_WHISPER_AHEADS_CUSTOM preset + /// See details https://github.com/ggerganov/whisper.cpp/pull/1485#discussion_r1519681143 + pub dtw_aheads: whisper_rs_sys::whisper_aheads, + /// Memory size for DTW + /// + /// **Warning**: Might be removed in next version of whisper.cpp + pub dtw_mem_size : usize } #[allow(clippy::derivable_impls)] // this impl cannot be derived @@ -559,6 +574,12 @@ impl Default for WhisperContextParameters { fn default() -> Self { Self { use_gpu: cfg!(feature = "_gpu"), + gpu_device: 0, + dtw_token_timestamps: false, + dtw_aheads_preset : whisper_rs_sys::whisper_alignment_heads_preset_WHISPER_AHEADS_NONE, + dtw_n_top: -1, + dtw_aheads : whisper_rs_sys::whisper_aheads { n_heads: 0, heads: std::ptr::null() }, + dtw_mem_size : 1024 * 1024 * 128 } } } @@ -570,9 +591,39 @@ impl WhisperContextParameters { self.use_gpu = use_gpu; self } + pub fn gpu_device(&mut self, gpu_device: c_int) -> &mut Self { + self.gpu_device = gpu_device; + self + } + pub fn dtw_token_timestamps(&mut self, dtw_token_timestamps: bool) -> &mut Self { + self.dtw_token_timestamps = dtw_token_timestamps; + self + } + pub fn dtw_aheads_preset(&mut self, dtw_aheads_preset: whisper_rs_sys::whisper_alignment_heads_preset) -> &mut Self { + self.dtw_aheads_preset = dtw_aheads_preset; + self + } + pub fn dtw_n_top(&mut self, dtw_n_top: c_int) -> &mut Self { + self.dtw_n_top = dtw_n_top; + self + } + pub fn dtw_aheads(&mut self, dtw_aheads: whisper_rs_sys::whisper_aheads) -> &mut Self { + self.dtw_aheads = dtw_aheads; + self + } + pub fn dtw_mem_size(&mut self, dtw_mem_size: usize) -> &mut Self { + self.dtw_mem_size = dtw_mem_size; + self + } fn to_c_struct(&self) -> whisper_rs_sys::whisper_context_params { whisper_rs_sys::whisper_context_params { use_gpu: self.use_gpu, + gpu_device: self.gpu_device, + dtw_token_timestamps: self.dtw_token_timestamps, + dtw_aheads_preset: self.dtw_aheads_preset, + dtw_n_top: self.dtw_n_top, + dtw_aheads: self.dtw_aheads, + dtw_mem_size: self.dtw_mem_size, } } } diff --git a/sys/Cargo.toml b/sys/Cargo.toml index a6ddf80..d0ebdd2 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "whisper-rs-sys" -version = "0.8.1" +version = "0.10.0" edition = "2021" description = "Rust bindings for whisper.cpp (FFI bindings)" license = "Unlicense" diff --git a/sys/build.rs b/sys/build.rs index 0535637..c2560dc 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -121,7 +121,7 @@ fn main() { } if cfg!(feature = "cuda") { - config.define("WHISPER_CUBLAS", "ON"); + config.define("WHISPER_CUDA", "ON"); } if cfg!(feature = "openblas") { diff --git a/sys/whisper.cpp b/sys/whisper.cpp index 0b9af32..7395c70 160000 --- a/sys/whisper.cpp +++ b/sys/whisper.cpp @@ -1 +1 @@ -Subproject commit 0b9af32a8b3fa7e2ae5f15a9a08f5b10394993f5 +Subproject commit 7395c70a748753e3800b63e3422a2b558a097c80