Add RNN LM rescore for offline ASR with modified_beam_search (#125)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "sherpa-onnx/csrc/file-utils.h"
|
||||
#include "sherpa-onnx/csrc/macros.h"
|
||||
#include "sherpa-onnx/csrc/offline-lm-config.h"
|
||||
#include "sherpa-onnx/csrc/offline-recognizer-impl.h"
|
||||
|
||||
namespace sherpa_onnx {
|
||||
@@ -15,13 +16,28 @@ namespace sherpa_onnx {
|
||||
void OfflineRecognizerConfig::Register(ParseOptions *po) {
|
||||
feat_config.Register(po);
|
||||
model_config.Register(po);
|
||||
lm_config.Register(po);
|
||||
|
||||
po->Register("decoding-method", &decoding_method,
|
||||
"decoding method,"
|
||||
"Valid values: greedy_search.");
|
||||
po->Register(
|
||||
"decoding-method", &decoding_method,
|
||||
"decoding method,"
|
||||
"Valid values: greedy_search, modified_beam_search. "
|
||||
"modified_beam_search is applicable only for transducer models.");
|
||||
|
||||
po->Register("max-active-paths", &max_active_paths,
|
||||
"Used only when decoding_method is modified_beam_search");
|
||||
}
|
||||
|
||||
bool OfflineRecognizerConfig::Validate() const {
|
||||
if (decoding_method == "modified_beam_search" && !lm_config.model.empty()) {
|
||||
if (max_active_paths <= 0) {
|
||||
SHERPA_ONNX_LOGE("max_active_paths is less than 0! Given: %d",
|
||||
max_active_paths);
|
||||
return false;
|
||||
}
|
||||
if (!lm_config.Validate()) return false;
|
||||
}
|
||||
|
||||
return model_config.Validate();
|
||||
}
|
||||
|
||||
@@ -31,7 +47,9 @@ std::string OfflineRecognizerConfig::ToString() const {
|
||||
os << "OfflineRecognizerConfig(";
|
||||
os << "feat_config=" << feat_config.ToString() << ", ";
|
||||
os << "model_config=" << model_config.ToString() << ", ";
|
||||
os << "decoding_method=\"" << decoding_method << "\")";
|
||||
os << "lm_config=" << lm_config.ToString() << ", ";
|
||||
os << "decoding_method=\"" << decoding_method << "\", ";
|
||||
os << "max_active_paths=" << max_active_paths << ")";
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user