diff --git a/examples/bench/bench.cpp b/examples/bench/bench.cpp index 979dca8e..1512f316 100644 --- a/examples/bench/bench.cpp +++ b/examples/bench/bench.cpp @@ -67,6 +67,10 @@ static int whisper_bench_full(const whisper_params & params) { cparams.flash_attn = params.flash_attn; struct whisper_context * ctx = whisper_init_from_file_with_params(params.model.c_str(), cparams); + if (ctx == nullptr) { + fprintf(stderr, "error: failed to initialize whisper context\n"); + return 2; + } { fprintf(stderr, "\n"); diff --git a/examples/command/command.cpp b/examples/command/command.cpp index 7a09d30a..0f87710c 100644 --- a/examples/command/command.cpp +++ b/examples/command/command.cpp @@ -709,6 +709,10 @@ int main(int argc, char ** argv) { cparams.flash_attn = params.flash_attn; struct whisper_context * ctx = whisper_init_from_file_with_params(params.model.c_str(), cparams); + if (ctx == nullptr) { + fprintf(stderr, "error: failed to initialize whisper context\n"); + return 2; + } // print some info about the processing { diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp index bc6f13fb..37b23886 100644 --- a/examples/stream/stream.cpp +++ b/examples/stream/stream.cpp @@ -163,6 +163,10 @@ int main(int argc, char ** argv) { cparams.flash_attn = params.flash_attn; struct whisper_context * ctx = whisper_init_from_file_with_params(params.model.c_str(), cparams); + if (ctx == nullptr) { + fprintf(stderr, "error: failed to initialize whisper context\n"); + return 2; + } std::vector pcmf32 (n_samples_30s, 0.0f); std::vector pcmf32_old; diff --git a/examples/vad-speech-segments/speech.cpp b/examples/vad-speech-segments/speech.cpp index 26241d95..a22425c4 100644 --- a/examples/vad-speech-segments/speech.cpp +++ b/examples/vad-speech-segments/speech.cpp @@ -111,6 +111,10 @@ int main(int argc, char ** argv) { struct whisper_vad_context * vctx = whisper_vad_init_from_file_with_params( cli_params.vad_model.c_str(), ctx_params); + if (vctx == nullptr) { + fprintf(stderr, "error: failed to initialize whisper context\n"); + return 2; + } // Detect speech in the input audio file. if (!whisper_vad_detect_speech(vctx, pcmf32.data(), pcmf32.size())) {