From 0ad085f5e88576034adc871600da296ff8016803 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 15 Oct 2022 09:55:28 +0300 Subject: [PATCH] ref #48 : clear results at the start of whisper_full This way, even if the input audio is empty, the previous results will be removed. --- whisper.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/whisper.cpp b/whisper.cpp index a5f79d2..b984c46 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -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__); @@ -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;