Skip to content

Commit

Permalink
ref ggerganov#48 : clear results at the start of whisper_full
Browse files Browse the repository at this point in the history
This way, even if the input audio is empty, the previous results will be
removed.
  • Loading branch information
ggerganov committed Oct 15, 2022
1 parent 3694516 commit 0ad085f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,12 @@ int whisper_full(
struct whisper_full_params params,
const float * samples,
int n_samples) {
// clear old results
auto & result_all = ctx->result_all;
auto & result_cur = ctx->result_cur;

result_all.clear();

// compute log mel spectrogram
if (whisper_pcm_to_mel(ctx, samples, n_samples, params.n_threads) != 0) {
fprintf(stderr, "%s: failed to compute log mel spectrogram\n", __func__);
Expand Down Expand Up @@ -2344,11 +2350,6 @@ int whisper_full(
}
}

auto & result_all = ctx->result_all;
auto & result_cur = ctx->result_cur;

result_all.clear();

int progress_prev = 0;
int progress_step = 5;

Expand Down

0 comments on commit 0ad085f

Please sign in to comment.