whisper_cpp_plus_sys/
lib.rs1#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#![allow(improper_ctypes)]
7
8include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
10
11pub const WHISPER_ERR_INVALID_MODEL: i32 = -1;
14pub const WHISPER_ERR_NOT_ENOUGH_MEMORY: i32 = -2;
15pub const WHISPER_ERR_FAILED_TO_PROCESS: i32 = -3;
16pub const WHISPER_ERR_INVALID_CONTEXT: i32 = -4;
17
18#[cfg(feature = "quantization")]
20pub const WHISPER_QUANTIZE_OK: i32 = 0;
21#[cfg(feature = "quantization")]
22pub const WHISPER_QUANTIZE_ERROR_INVALID_MODEL: i32 = -1;
23#[cfg(feature = "quantization")]
24pub const WHISPER_QUANTIZE_ERROR_FILE_OPEN: i32 = -2;
25#[cfg(feature = "quantization")]
26pub const WHISPER_QUANTIZE_ERROR_FILE_WRITE: i32 = -3;
27#[cfg(feature = "quantization")]
28pub const WHISPER_QUANTIZE_ERROR_INVALID_FTYPE: i32 = -4;
29#[cfg(feature = "quantization")]
30pub const WHISPER_QUANTIZE_ERROR_QUANTIZATION_FAILED: i32 = -5;
31
32pub const GGML_FTYPE_UNKNOWN: i32 = -1;
34pub const GGML_FTYPE_ALL_F32: i32 = 0;
35pub const GGML_FTYPE_MOSTLY_F16: i32 = 1;
36pub const GGML_FTYPE_MOSTLY_Q4_0: i32 = 2;
37pub const GGML_FTYPE_MOSTLY_Q4_1: i32 = 3;
38pub const GGML_FTYPE_MOSTLY_Q4_1_SOME_F16: i32 = 4;
39pub const GGML_FTYPE_MOSTLY_Q8_0: i32 = 7;
40pub const GGML_FTYPE_MOSTLY_Q5_0: i32 = 8;
41pub const GGML_FTYPE_MOSTLY_Q5_1: i32 = 9;
42pub const GGML_FTYPE_MOSTLY_Q2_K: i32 = 10;
43pub const GGML_FTYPE_MOSTLY_Q3_K: i32 = 11;
44pub const GGML_FTYPE_MOSTLY_Q4_K: i32 = 12;
45pub const GGML_FTYPE_MOSTLY_Q5_K: i32 = 13;
46pub const GGML_FTYPE_MOSTLY_Q6_K: i32 = 14;
47
48#[cfg(feature = "quantization")]
50pub type whisper_quantize_progress_callback = Option<extern "C" fn(progress: f32)>;
51
52#[cfg(feature = "quantization")]
53extern "C" {
54 pub fn whisper_model_quantize(
66 fname_inp: *const ::std::os::raw::c_char,
67 fname_out: *const ::std::os::raw::c_char,
68 ftype: ::std::os::raw::c_int,
69 progress_callback: whisper_quantize_progress_callback,
70 ) -> ::std::os::raw::c_int;
71
72 pub fn whisper_model_get_ftype(
81 fname: *const ::std::os::raw::c_char,
82 ) -> ::std::os::raw::c_int;
83}
84
85#[cfg(test)]
86mod tests {
87 use super::*;
88
89 #[test]
90 fn test_constants_defined() {
91 assert_eq!(WHISPER_ERR_INVALID_MODEL, -1);
93 assert_eq!(WHISPER_ERR_NOT_ENOUGH_MEMORY, -2);
94 assert_eq!(WHISPER_ERR_FAILED_TO_PROCESS, -3);
95 assert_eq!(WHISPER_ERR_INVALID_CONTEXT, -4);
96 }
97}