{"record":{"id":"323ba5d7bf531611","repo":"mudler/LocalAI","slug":"error-failed-to-init-model-as-vad-n","errorCode":null,"errorMessage":"error: Failed to init model as VAD\\n","messagePattern":"error: Failed to init model as VAD\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/go/crispasr/cpp/crispasr_shim.cpp","lineNumber":190,"sourceCode":"// success or when the active backend needs no companion, negative on failure,\n// and -1 when no session is open.\nint set_codec_path(const char *path) {\n  return g_session ? crispasr_session_set_codec_path(g_session, path) : -1;\n}\n\nint load_model_vad(const char *const model_path) {\n  whisper_log_set(ggml_log_cb, nullptr);\n  ggml_backend_load_all();\n\n  struct whisper_vad_context_params vcparams =\n      whisper_vad_default_context_params();\n\n  // XXX: Overridden to false in upstream due to performance?\n  // vcparams.use_gpu = true;\n\n  vctx = whisper_vad_init_from_file_with_params(model_path, vcparams);\n  if (vctx == nullptr) {\n    fprintf(stderr, \"error: Failed to init model as VAD\\n\");\n    return 1;\n  }\n\n  return 0;\n}\n\nint vad(float pcmf32[], size_t pcmf32_len, float **segs_out,\n        size_t *segs_out_len) {\n  if (!whisper_vad_detect_speech(vctx, pcmf32, pcmf32_len)) {\n    fprintf(stderr, \"error: failed to detect speech\\n\");\n    return 1;\n  }\n\n  struct whisper_vad_params params = whisper_vad_default_params();\n  struct whisper_vad_segments *segs =\n      whisper_vad_segments_from_probs(vctx, params);\n  size_t segn = whisper_vad_segments_n_segments(segs);\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/crispasr/cpp/crispasr_shim.cpp#L172-L208","documentation":"load_model_vad() failed because whisper_vad_init_from_file_with_params() returned NULL for the given model path — the file could not be initialized as a Whisper VAD model. Note the shim explicitly leaves use_gpu at its default (the upstream override is commented out), so both file-level and init-level causes surface here. Returns 1.","triggerScenarios":"load_model_vad(path) where path is missing, not a valid VAD checkpoint (e.g., a regular ASR model without VAD head), or whisper VAD init fails on the current backend.","commonSituations":"Passing a standard whisper ASR GGUF where the dedicated VAD model (silero-style vad checkpoint) is required; wrong path in config; truncated download; whisper.cpp version bundled does not support the VAD model format.","solutions":["Confirm the path points to the dedicated Whisper VAD model, not a transcription model.","Verify file integrity (size/hash against the gallery entry).","Check ggml logs above the error for the concrete init failure.","Ensure the bundled whisper.cpp has VAD support compiled in."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := os.Stat(vadModelPath); err != nil {\n    return fmt.Errorf(\"VAD model missing: %w\", err)\n}\nif rc := C.load_model_vad(C.CString(vadModelPath)); rc != 0 {\n    return errors.New(\"VAD init failed; is this the dedicated VAD checkpoint?\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the dedicated VAD checkpoint, not an ASR model.","Gate the VAD code path on a successful load_model_vad return."],"tags":["crispasr","vad","whisper","model-loading"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}