@brief Ensure the asr model is loaded @param model_tag the model tag
| 415 | ///@brief Ensure the asr model is loaded |
| 416 | ///@param model_tag the model tag |
| 417 | void RestHandler::ensure_asr_model_loaded(const std::string& model_tag) { |
| 418 | #ifndef FASTFLOWLM_LINUX_LIMITED_MODELS |
| 419 | std::string ensure_tag = model_tag; |
| 420 | if (!downloader.is_model_downloaded(ensure_tag)) { |
| 421 | downloader.pull_model(ensure_tag); |
| 422 | } |
| 423 | this->whisper_engine = std::make_unique<Whisper>(&this->npu_device_inst); |
| 424 | auto [new_ensure_tag, whisper_model_info] = this->supported_models.get_model_info(ensure_tag); |
| 425 | std::string whisper_model_path = this->supported_models.get_model_path(new_ensure_tag); |
| 426 | try { |
| 427 | this->whisper_engine->load_model(whisper_model_path, whisper_model_info, this->preemption); |
| 428 | } |
| 429 | catch (const std::exception& e) { |
| 430 | header_print("ERROR", "Failed to load ASR model: " + std::string(e.what())); |
| 431 | exit(EXIT_FAILURE); |
| 432 | } |
| 433 | #else |
| 434 | throw std::runtime_error("ASR models are not supported in this build"); |
| 435 | #endif |
| 436 | } |
| 437 | |
| 438 | ///@brief Ensure the embed model is loaded |
| 439 | ///@param model_tag the model tag |
nothing calls this directly
no test coverage detected