Skip to content

Commit

Permalink
whisper : move new-segment callback after DTW step (ggerganov#2515)
Browse files Browse the repository at this point in the history
  • Loading branch information
jettoblack authored and liuyang.marshall committed Nov 2, 2024
1 parent bd53ce1 commit 8ba5218
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6202,7 +6202,7 @@ int whisper_full_with_state(
n_new = whisper_wrap_segment(*ctx, *state, params.max_len, params.split_on_word);
}
}
if (params.new_segment_callback) {
if (params.new_segment_callback && !ctx->params.dtw_token_timestamps) {
params.new_segment_callback(ctx, state, n_new, params.new_segment_callback_user_data);
}
}
Expand Down Expand Up @@ -6247,7 +6247,7 @@ int whisper_full_with_state(
n_new = whisper_wrap_segment(*ctx, *state, params.max_len, params.split_on_word);
}
}
if (params.new_segment_callback) {
if (params.new_segment_callback && !ctx->params.dtw_token_timestamps) {
params.new_segment_callback(ctx, state, n_new, params.new_segment_callback_user_data);
}
}
Expand All @@ -6261,6 +6261,11 @@ int whisper_full_with_state(
const int n_frames = std::min(std::min(WHISPER_CHUNK_SIZE * 100, seek_delta), seek_end - seek);
whisper_exp_compute_token_level_timestamps_dtw(
ctx, state, params, result_all.size() - n_segments, n_segments, seek, n_frames, 7, params.n_threads);
if (params.new_segment_callback) {
for (int seg = (int) result_all.size() - n_segments; seg < n_segments; seg++) {
params.new_segment_callback(ctx, state, seg, params.new_segment_callback_user_data);
}
}
}
}

Expand Down

0 comments on commit 8ba5218

Please sign in to comment.