Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep kaldi-serve from crashing if an expected model is not found #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion plugins/grpc/src/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ class KaldiServeImpl final : public kaldi_serve::KaldiServe::Service {
KaldiServeImpl::KaldiServeImpl(const std::vector<ModelSpec> &model_specs) noexcept {
for (auto const &model_spec : model_specs) {
model_id_t model_id = std::make_pair(model_spec.name, model_spec.language_code);
decoder_queue_map_[model_id] = std::unique_ptr<DecoderQueue>(new DecoderQueue(model_spec));
try {
decoder_queue_map_[model_id] = std::unique_ptr<DecoderQueue>(new DecoderQueue(model_spec));;
} catch (const std::runtime_error &e) {
std::cerr<<"Model not loaded: ("<<model_id.first<<","<<model_id.second<<"). This raised an error:"<<e.what()<<"\n";
// Expected while creation of ChainModel. Eg- when kaldi model is missing.
// This catch keeps kaldi-serve from exiting due to this error.
// Do nothing here. `decoder_queue_map_` will simply not contain an entry for key `model_id`.
}
}
}

Expand Down