Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hallucinations during silence #2629

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6060,7 +6060,7 @@ int whisper_full_with_state(
{
const auto & best_decoder = state->decoders[best_decoder_id];

const auto seek_delta = best_decoder.seek_delta;
auto seek_delta = best_decoder.seek_delta;
const auto result_len = best_decoder.sequence.result_len;

const auto & tokens_cur = best_decoder.sequence.tokens;
Expand Down Expand Up @@ -6201,6 +6201,15 @@ int whisper_full_with_state(
}
}

// ref: https://github.com/ggerganov/whisper.cpp/pull/2629
const bool single_timestamp_ending = tokens_cur.size() > 1 &&
tokens_cur[tokens_cur.size() - 2].id < whisper_token_beg(ctx) &&
tokens_cur[tokens_cur.size() - 1].id > whisper_token_beg(ctx);
if (single_timestamp_ending) {
WHISPER_LOG_DEBUG("single timestamp ending - skip entire chunk\n");
seek_delta = std::min(seek_end - seek, WHISPER_CHUNK_SIZE * 100);
}

// update audio window
seek += seek_delta;

Expand Down