]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
ref #48 : clear results at the start of whisper_full
authorGeorgi Gerganov <redacted>
Sat, 15 Oct 2022 06:55:28 +0000 (09:55 +0300)
committerGeorgi Gerganov <redacted>
Sat, 15 Oct 2022 06:55:28 +0000 (09:55 +0300)
This way, even if the input audio is empty, the previous results will be
removed.

whisper.cpp

index a5f79d255cdf4c94d6bedd4e6013ddf41af52a6a..b984c4609a5aea98b07d7f50c89cb564b742fe0b 100644 (file)
@@ -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;