Merge pull request #85 from tazz4843/whisper-8e46ba8
Update `whisper.cpp` to 8e46ba8
This commit is contained in:
commit
6e864d96b2
6 changed files with 82 additions and 20 deletions
|
|
@ -67,7 +67,7 @@ See [BUILDING.md](BUILDING.md) for instructions for building whisper-rs on Windo
|
|||
## Troubleshooting
|
||||
|
||||
* Something other than Windows/macOS/Linux isn't working!
|
||||
* I don't have a way to test this platforms, so I can't really help you.
|
||||
* I don't have a way to test these platforms, so I can't really help you.
|
||||
* If you can get it working, please open a PR with any changes to make it work and build instructions in BUILDING.md!
|
||||
* I get a panic during binding generation build!
|
||||
* You can attempt to fix it yourself, or you can set the `WHISPER_DONT_GENERATE_BINDINGS` environment variable.
|
||||
|
|
|
|||
|
|
@ -24,3 +24,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 WhisperLogCallback = whisper_rs_sys::whisper_log_callback;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
//! Standalone functions that have no associated type.
|
||||
|
||||
use crate::WhisperToken;
|
||||
use std::ffi::{c_int, CStr, CString};
|
||||
|
||||
/// Return the id of the specified language, returns -1 if not found
|
||||
|
|
@ -54,21 +53,12 @@ pub fn get_lang_str(id: i32) -> Option<&'static str> {
|
|||
}
|
||||
}
|
||||
|
||||
// task tokens
|
||||
/// Get the ID of the translate task token.
|
||||
/// Callback to control logging output: default behaviour is to print to stderr.
|
||||
///
|
||||
/// # C++ equivalent
|
||||
/// `whisper_token whisper_token_translate ()`
|
||||
pub fn token_translate() -> WhisperToken {
|
||||
unsafe { whisper_rs_sys::whisper_token_translate() }
|
||||
}
|
||||
|
||||
/// Get the ID of the transcribe task token.
|
||||
///
|
||||
/// # C++ equivalent
|
||||
/// `whisper_token whisper_token_transcribe()`
|
||||
pub fn token_transcribe() -> WhisperToken {
|
||||
unsafe { whisper_rs_sys::whisper_token_transcribe() }
|
||||
/// `void whisper_set_log_callback(whisper_log_callback callback);`
|
||||
pub unsafe fn set_log_callback(callback: whisper_rs_sys::whisper_log_callback) {
|
||||
unsafe { whisper_rs_sys::whisper_set_log_callback(callback) }
|
||||
}
|
||||
|
||||
/// Print system information.
|
||||
|
|
|
|||
|
|
@ -367,6 +367,15 @@ impl WhisperContext {
|
|||
unsafe { whisper_rs_sys::whisper_token_sot(self.ctx) }
|
||||
}
|
||||
|
||||
/// Get the ID of the solm token.
|
||||
///
|
||||
/// # C++ equivalent
|
||||
/// `whisper_token whisper_token_solm(struct whisper_context * ctx)`
|
||||
#[inline]
|
||||
pub fn token_solm(&self) -> WhisperToken {
|
||||
unsafe { whisper_rs_sys::whisper_token_solm(self.ctx) }
|
||||
}
|
||||
|
||||
/// Get the ID of the prev token.
|
||||
///
|
||||
/// # C++ equivalent
|
||||
|
|
@ -376,13 +385,13 @@ impl WhisperContext {
|
|||
unsafe { whisper_rs_sys::whisper_token_prev(self.ctx) }
|
||||
}
|
||||
|
||||
/// Get the ID of the solm token.
|
||||
/// Get the ID of the nosp token.
|
||||
///
|
||||
/// # C++ equivalent
|
||||
/// `whisper_token whisper_token_solm(struct whisper_context * ctx)`
|
||||
/// `whisper_token whisper_token_nosp(struct whisper_context * ctx)`
|
||||
#[inline]
|
||||
pub fn token_solm(&self) -> WhisperToken {
|
||||
unsafe { whisper_rs_sys::whisper_token_solm(self.ctx) }
|
||||
pub fn token_nosp(&self) -> WhisperToken {
|
||||
unsafe { whisper_rs_sys::whisper_token_nosp(self.ctx) }
|
||||
}
|
||||
|
||||
/// Get the ID of the not token.
|
||||
|
|
@ -432,6 +441,23 @@ impl WhisperContext {
|
|||
pub fn reset_timings(&self) {
|
||||
unsafe { whisper_rs_sys::whisper_reset_timings(self.ctx) }
|
||||
}
|
||||
|
||||
// task tokens
|
||||
/// Get the ID of the translate task token.
|
||||
///
|
||||
/// # C++ equivalent
|
||||
/// `whisper_token whisper_token_translate ()`
|
||||
pub fn token_translate(&self) -> WhisperToken {
|
||||
unsafe { whisper_rs_sys::whisper_token_translate(self.ctx) }
|
||||
}
|
||||
|
||||
/// Get the ID of the transcribe task token.
|
||||
///
|
||||
/// # C++ equivalent
|
||||
/// `whisper_token whisper_token_transcribe()`
|
||||
pub fn token_transcribe(&self) -> WhisperToken {
|
||||
unsafe { whisper_rs_sys::whisper_token_transcribe(self.ctx) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WhisperContext {
|
||||
|
|
|
|||
|
|
@ -206,6 +206,15 @@ impl<'a, 'b> FullParams<'a, 'b> {
|
|||
self.fp.speed_up = speed_up;
|
||||
}
|
||||
|
||||
/// # EXPERIMENTAL
|
||||
///
|
||||
/// Enables debug mode, such as dumping the log mel spectrogram.
|
||||
///
|
||||
/// Defaults to false.
|
||||
pub fn set_debug_mode(&mut self, debug: bool) {
|
||||
self.fp.debug_mode = debug;
|
||||
}
|
||||
|
||||
/// # EXPERIMENTAL
|
||||
///
|
||||
/// Overwrite the audio context size. 0 = default.
|
||||
|
|
@ -216,6 +225,16 @@ impl<'a, 'b> FullParams<'a, 'b> {
|
|||
self.fp.audio_ctx = audio_ctx;
|
||||
}
|
||||
|
||||
/// # EXPERIMENTAL
|
||||
///
|
||||
/// Enable tinydiarize support.
|
||||
/// Experimental speaker turn detection.
|
||||
///
|
||||
/// Defaults to false.
|
||||
pub fn set_tdrz_enable(&mut self, tdrz_enable: bool) {
|
||||
self.fp.tdrz_enable = tdrz_enable;
|
||||
}
|
||||
|
||||
/// Set tokens to provide the model as initial input.
|
||||
///
|
||||
/// These tokens are prepended to any existing text content from a previous call.
|
||||
|
|
@ -485,6 +504,31 @@ impl<'a, 'b> FullParams<'a, 'b> {
|
|||
) {
|
||||
self.fp.logits_filter_callback_user_data = user_data;
|
||||
}
|
||||
|
||||
/// Set the callback that is called each time before ggml computation starts.
|
||||
///
|
||||
/// Note that this callback has not been Rustified yet (and likely never will be, unless someone else feels the need to do so).
|
||||
/// It is still a C callback.
|
||||
///
|
||||
/// # Safety
|
||||
/// Do not use this function unless you know what you are doing.
|
||||
/// * Be careful not to mutate the state of the whisper_context pointer returned in the callback.
|
||||
/// This could cause undefined behavior, as this violates the thread-safety guarantees of the underlying C library.
|
||||
///
|
||||
/// Defaults to None.
|
||||
pub unsafe fn set_abort_callback(&mut self, abort_callback: crate::WhisperAbortCallback) {
|
||||
self.fp.abort_callback = abort_callback;
|
||||
}
|
||||
|
||||
/// Set the user data to be passed to the abort callback.
|
||||
///
|
||||
/// # Safety
|
||||
/// See the safety notes for `set_abort_callback`.
|
||||
///
|
||||
/// Defaults to None.
|
||||
pub unsafe fn set_abort_callback_user_data(&mut self, user_data: *mut std::ffi::c_void) {
|
||||
self.fp.abort_callback_user_data = user_data;
|
||||
}
|
||||
}
|
||||
|
||||
// following implementations are safe
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit a5defbc1b98bea0f070331ce1e8b62d947b0443d
|
||||
Subproject commit 91c0b23384fc3725013c4b6d3b35c45ad92dea0a
|
||||
Loading…
Add table
Add a link
Reference in a new issue