diff --git a/examples/cli/cli.cpp b/examples/cli/cli.cpp index c64976a5637..55d5d4336d2 100644 --- a/examples/cli/cli.cpp +++ b/examples/cli/cli.cpp @@ -968,8 +968,6 @@ static void output_lrc(struct whisper_context * ctx, std::ofstream & fout, const static void cb_log_disable(enum ggml_log_level , const char * , void * ) { } int main(int argc, char ** argv) { - ggml_backend_load_all(); - #if defined(_WIN32) // Set the console output code page to UTF-8, while command line arguments // are still encoded in the system's code page. In this way, we can print @@ -1032,6 +1030,12 @@ int main(int argc, char ** argv) { return 2; } + if (!is_file_exist(params.model.c_str())) { + fprintf(stderr, "error: model file not found '%s'\n", params.model.c_str()); + whisper_print_usage(argc, argv, params); + return 3; + } + if (params.language != "auto" && whisper_lang_id(params.language.c_str()) == -1) { fprintf(stderr, "error: unknown language '%s'\n", params.language.c_str()); whisper_print_usage(argc, argv, params); @@ -1048,6 +1052,8 @@ int main(int argc, char ** argv) { whisper_log_set(cb_log_disable, NULL); } + ggml_backend_load_all(); + // whisper init struct whisper_context_params cparams = whisper_context_default_params();