Merge branch 'tazz4843:master' into fix/progress-callback-crash
This commit is contained in:
commit
4acdc92236
1 changed files with 22 additions and 34 deletions
|
|
@ -419,26 +419,20 @@ impl<'a, 'b> FullParams<'a, 'b> {
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
let user_data = &mut *(user_data as *mut SegmentCallbackFn);
|
let user_data = &mut *(user_data as *mut SegmentCallbackFn);
|
||||||
let n_segments = whisper_rs_sys::whisper_full_n_segments_from_state(state);
|
let text = whisper_rs_sys::whisper_full_get_segment_text_from_state(state, n_new);
|
||||||
let s0 = n_segments - n_new;
|
let text = CStr::from_ptr(text);
|
||||||
//let user_data = user_data as *mut Box<dyn FnMut(SegmentCallbackData)>;
|
|
||||||
|
|
||||||
for i in s0..n_segments {
|
let t0 = whisper_rs_sys::whisper_full_get_segment_t0_from_state(state, n_new);
|
||||||
let text = whisper_rs_sys::whisper_full_get_segment_text_from_state(state, i);
|
let t1 = whisper_rs_sys::whisper_full_get_segment_t1_from_state(state, n_new);
|
||||||
let text = CStr::from_ptr(text);
|
|
||||||
|
|
||||||
let t0 = whisper_rs_sys::whisper_full_get_segment_t0_from_state(state, i);
|
match text.to_str() {
|
||||||
let t1 = whisper_rs_sys::whisper_full_get_segment_t1_from_state(state, i);
|
Ok(n) => user_data(SegmentCallbackData {
|
||||||
|
segment: n_new + 1,
|
||||||
match text.to_str() {
|
start_timestamp: t0,
|
||||||
Ok(n) => user_data(SegmentCallbackData {
|
end_timestamp: t1,
|
||||||
segment: i,
|
text: n.to_string(),
|
||||||
start_timestamp: t0,
|
}),
|
||||||
end_timestamp: t1,
|
Err(_) => {}
|
||||||
text: n.to_string(),
|
|
||||||
}),
|
|
||||||
Err(_) => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -488,23 +482,17 @@ impl<'a, 'b> FullParams<'a, 'b> {
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
let user_data = &mut *(user_data as *mut SegmentCallbackFn);
|
let user_data = &mut *(user_data as *mut SegmentCallbackFn);
|
||||||
let n_segments = whisper_rs_sys::whisper_full_n_segments_from_state(state);
|
let text = whisper_rs_sys::whisper_full_get_segment_text_from_state(state, n_new);
|
||||||
let s0 = n_segments - n_new;
|
let text = CStr::from_ptr(text);
|
||||||
//let user_data = user_data as *mut Box<dyn FnMut(SegmentCallbackData)>;
|
|
||||||
|
|
||||||
for i in s0..n_segments {
|
let t0 = whisper_rs_sys::whisper_full_get_segment_t0_from_state(state, n_new);
|
||||||
let text = whisper_rs_sys::whisper_full_get_segment_text_from_state(state, i);
|
let t1 = whisper_rs_sys::whisper_full_get_segment_t1_from_state(state, n_new);
|
||||||
let text = CStr::from_ptr(text);
|
user_data(SegmentCallbackData {
|
||||||
|
segment: n_new,
|
||||||
let t0 = whisper_rs_sys::whisper_full_get_segment_t0_from_state(state, i);
|
start_timestamp: t0,
|
||||||
let t1 = whisper_rs_sys::whisper_full_get_segment_t1_from_state(state, i);
|
end_timestamp: t1,
|
||||||
user_data(SegmentCallbackData {
|
text: text.to_string_lossy().to_string(),
|
||||||
segment: i,
|
});
|
||||||
start_timestamp: t0,
|
|
||||||
end_timestamp: t1,
|
|
||||||
text: text.to_string_lossy().to_string(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue