Fix print_system_info return value

This commit is contained in:
Ephraim Kunz 2022-11-22 10:10:03 -07:00
parent 520ea9d4d8
commit d3825debff
4 changed files with 11 additions and 7 deletions

View File

@ -1,7 +1,7 @@
//! Standalone functions that have no associated type. //! Standalone functions that have no associated type.
use crate::WhisperToken; use crate::WhisperToken;
use std::ffi::{c_int, CString}; use std::ffi::{c_int, CStr, CString};
/// Return the id of the specified language, returns -1 if not found /// Return the id of the specified language, returns -1 if not found
/// ///
@ -47,6 +47,8 @@ pub fn token_transcribe() -> WhisperToken {
/// ///
/// # C++ equivalent /// # C++ equivalent
/// `const char * whisper_print_system_info()` /// `const char * whisper_print_system_info()`
pub fn print_system_info() { pub fn print_system_info() -> &'static str {
unsafe { whisper_rs_sys::whisper_print_system_info() }; 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()
} }

View File

@ -111,6 +111,7 @@ pub fn convert_stereo_to_mono_audio_simd(samples: &[f32]) -> Vec<f32> {
mono mono
} }
#[cfg(feature = "simd")]
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;

View File

@ -363,7 +363,7 @@ impl WhisperContext {
unsafe { whisper_rs_sys::whisper_token_beg(self.ctx) } unsafe { whisper_rs_sys::whisper_token_beg(self.ctx) }
} }
/// Print performance statistics to stdout. /// Print performance statistics to stderr.
/// ///
/// # C++ equivalent /// # C++ equivalent
/// `void whisper_print_timings(struct whisper_context * ctx)` /// `void whisper_print_timings(struct whisper_context * ctx)`

View File

@ -12,7 +12,8 @@ fn main() {
let _: u64 = std::fs::copy( let _: u64 = std::fs::copy(
"src/bindings.rs", "src/bindings.rs",
env::var("OUT_DIR").unwrap() + "/bindings.rs", env::var("OUT_DIR").unwrap() + "/bindings.rs",
).expect("Failed to copy bindings.rs"); )
.expect("Failed to copy bindings.rs");
} else { } else {
let bindings = bindgen::Builder::default() let bindings = bindgen::Builder::default()
.header("wrapper.h") .header("wrapper.h")