Fix drop for VoskSession and made get_final_result consume the session

This commit is contained in:
Andrey Tkachenko 2020-08-20 12:50:59 +04:00
parent f1d8d9f11d
commit fcc0093c1c
2 changed files with 7 additions and 1 deletions

View File

@ -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()

View File

@ -101,3 +101,9 @@ impl VoskSession {
}
}
}
impl Drop for VoskSession {
fn drop(&mut self) {
unsafe { ffi::vosk_recognizer_free(self.inner) }
}
}