Print a more user-friendly error message when using --hotwords-file. (#344)
This commit is contained in:
@@ -46,7 +46,17 @@ bool OfflineRecognizerConfig::Validate() const {
|
||||
max_active_paths);
|
||||
return false;
|
||||
}
|
||||
if (!lm_config.Validate()) return false;
|
||||
if (!lm_config.Validate()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hotwords_file.empty() && decoding_method != "modified_beam_search") {
|
||||
SHERPA_ONNX_LOGE(
|
||||
"Please use --decoding-method=modified_beam_search if you"
|
||||
" provide --hotwords-file. Given --decoding-method=%s",
|
||||
decoding_method.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
return model_config.Validate();
|
||||
|
||||
@@ -156,8 +156,9 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl {
|
||||
bool has_context_graph = false;
|
||||
|
||||
for (int32_t i = 0; i != n; ++i) {
|
||||
if (!has_context_graph && ss[i]->GetContextGraph())
|
||||
if (!has_context_graph && ss[i]->GetContextGraph()) {
|
||||
has_context_graph = true;
|
||||
}
|
||||
|
||||
const auto num_processed_frames = ss[i]->GetNumProcessedFrames();
|
||||
std::vector<float> features =
|
||||
|
||||
@@ -102,8 +102,20 @@ bool OnlineRecognizerConfig::Validate() const {
|
||||
max_active_paths);
|
||||
return false;
|
||||
}
|
||||
if (!lm_config.Validate()) return false;
|
||||
|
||||
if (!lm_config.Validate()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hotwords_file.empty() && decoding_method != "modified_beam_search") {
|
||||
SHERPA_ONNX_LOGE(
|
||||
"Please use --decoding-method=modified_beam_search if you"
|
||||
" provide --hotwords-file. Given --decoding-method=%s",
|
||||
decoding_method.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
return model_config.Validate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user