use crate::WhisperToken;
use std::ffi::{c_int, CStr, CString};
pub fn get_lang_id(lang: &str) -> Option<c_int> {
let c_lang = CString::new(lang).expect("Language contains null byte");
let ret = unsafe { whisper_rs_sys::whisper_lang_id(c_lang.as_ptr()) };
if ret == -1 {
None
} else {
Some(ret)
}
}
pub fn get_lang_max_id() -> i32 {
unsafe { whisper_rs_sys::whisper_lang_max_id() }
}
pub fn get_lang_str(id: i32) -> Option<&'static str> {
let c_buf = unsafe { whisper_rs_sys::whisper_lang_str(id) };
if c_buf.is_null() {
None
} else {
let c_str = unsafe { CStr::from_ptr(c_buf) };
Some(c_str.to_str().unwrap())
}
}
pub fn token_translate() -> WhisperToken {
unsafe { whisper_rs_sys::whisper_token_translate() }
}
pub fn token_transcribe() -> WhisperToken {
unsafe { whisper_rs_sys::whisper_token_transcribe() }
}
pub fn print_system_info() -> &'static str {
let c_buf = unsafe { whisper_rs_sys::whisper_print_system_info() };
let c_str = unsafe { CStr::from_ptr(c_buf) };
c_str.to_str().unwrap()
}