From dc1e51fd34881259550147387369ea2a49d27066 Mon Sep 17 00:00:00 2001 From: Martin Destagnol Date: Wed, 17 Sep 2025 19:53:04 -1000 Subject: [PATCH] fix --- src/whisper.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/whisper.cpp b/src/whisper.cpp index f150bfcf..15ff4245 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -6802,23 +6802,12 @@ static bool whisper_vad( } int whisper_full_with_state( - struct whisper_context * ctx, - struct whisper_state * state, - struct whisper_full_params params, - const float * samples, - int n_samples) { - // clear old results - auto & result_all = state->result_all; - - result_all.clear(); - - if (n_samples > 0) { - // compute log mel spectrogram - if (whisper_pcm_to_mel_with_state(ctx, state, samples, n_samples, params.n_threads) != 0) { - WHISPER_LOG_ERROR("%s: failed to compute log mel spectrogram\n", __func__); - return -2; - } - } + struct whisper_context *ctx, + struct whisper_state *state, + struct whisper_full_params params, + const float *samples, + int n_samples) +{ std::vector vad_samples; if (params.vad) @@ -6838,6 +6827,21 @@ int whisper_full_with_state( n_samples = vad_samples.size(); } + // clear old results + auto &result_all = state->result_all; + + result_all.clear(); + + if (n_samples > 0) + { + // compute log mel spectrogram + if (whisper_pcm_to_mel_with_state(ctx, state, samples, n_samples, params.n_threads) != 0) + { + WHISPER_LOG_ERROR("%s: failed to compute log mel spectrogram\n", __func__); + return -2; + } + } + // auto-detect language if not specified if (params.language == nullptr || strlen(params.language) == 0 || strcmp(params.language, "auto") == 0 || params.detect_language) { std::vector probs(whisper_lang_max_id() + 1, 0.0f);