Fix drop for VoskSession and made get_final_result consume the session
This commit is contained in:
parent
f1d8d9f11d
commit
fcc0093c1c
@ -42,7 +42,7 @@ impl VoskModel {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_final_result(&self, sess: &mut VoskSession) -> crate::TranscriptionResult {
|
||||
pub fn get_final_result(&self, sess: VoskSession) -> crate::TranscriptionResult {
|
||||
let cstr = unsafe { CStr::from_ptr(ffi::vosk_recognizer_final_result(sess.inner)) };
|
||||
|
||||
serde_json::from_str(cstr.to_str().unwrap()).unwrap()
|
||||
|
@ -101,3 +101,9 @@ impl VoskSession {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for VoskSession {
|
||||
fn drop(&mut self) {
|
||||
unsafe { ffi::vosk_recognizer_free(self.inner) }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user