Add whisper_lang_str_full function to whisper-rs

This commit is contained in:
Andrii Kotliar 2024-01-08 01:24:38 +01:00
parent 22bf23a168
commit e195c885a1
3 changed files with 1584 additions and 1091 deletions

View file

@ -4,7 +4,7 @@ exclude = ["examples/full_usage"]
[package] [package]
name = "whisper-rs" name = "whisper-rs"
version = "0.10.0" version = "0.10.1"
edition = "2021" edition = "2021"
description = "Rust bindings for whisper.cpp" description = "Rust bindings for whisper.cpp"
license = "Unlicense" license = "Unlicense"

View file

@ -53,6 +53,23 @@ pub fn get_lang_str(id: i32) -> Option<&'static str> {
} }
} }
/// Get the full string of the specified language name (e.g. 2 -> "german").
///
/// # Returns
/// The full string of the language, None if not found.
///
/// # C++ equivalent
/// `const char * whisper_lang_str_full(int id)`
pub fn get_lang_str_full(id: i32) -> Option<&'static str> {
let c_buf = unsafe { whisper_rs_sys::whisper_lang_str_full(id) };
if c_buf.is_null() {
None
} else {
let c_str = unsafe { CStr::from_ptr(c_buf) };
Some(c_str.to_str().unwrap())
}
}
/// Callback to control logging output: default behaviour is to print to stderr. /// Callback to control logging output: default behaviour is to print to stderr.
/// ///
/// # Safety /// # Safety

File diff suppressed because it is too large Load diff