Re-implement LM rescore for online transducer (#1231)
Co-authored-by: Martins Kronis <martins.kuznecovs@tilde.lv>
This commit is contained in:
@@ -13,13 +13,16 @@ namespace sherpa_onnx {
|
||||
void PybindOnlineLMConfig(py::module *m) {
|
||||
using PyClass = OnlineLMConfig;
|
||||
py::class_<PyClass>(*m, "OnlineLMConfig")
|
||||
.def(py::init<const std::string &, float, int32_t, const std::string &>(),
|
||||
.def(py::init<const std::string &, float, int32_t,
|
||||
const std::string &, bool>(),
|
||||
py::arg("model") = "", py::arg("scale") = 0.5f,
|
||||
py::arg("lm_num_threads") = 1, py::arg("lm_provider") = "cpu")
|
||||
py::arg("lm_num_threads") = 1, py::arg("lm_provider") = "cpu",
|
||||
py::arg("shallow_fusion") = true)
|
||||
.def_readwrite("model", &PyClass::model)
|
||||
.def_readwrite("scale", &PyClass::scale)
|
||||
.def_readwrite("lm_provider", &PyClass::lm_provider)
|
||||
.def_readwrite("lm_num_threads", &PyClass::lm_num_threads)
|
||||
.def_readwrite("shallow_fusion", &PyClass::shallow_fusion)
|
||||
.def("__str__", &PyClass::ToString);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ class OnlineRecognizer(object):
|
||||
bpe_vocab: str = "",
|
||||
lm: str = "",
|
||||
lm_scale: float = 0.1,
|
||||
lm_shallow_fusion: bool = True,
|
||||
temperature_scale: float = 2.0,
|
||||
debug: bool = False,
|
||||
rule_fsts: str = "",
|
||||
@@ -274,6 +275,7 @@ class OnlineRecognizer(object):
|
||||
lm_config = OnlineLMConfig(
|
||||
model=lm,
|
||||
scale=lm_scale,
|
||||
shallow_fusion=lm_shallow_fusion,
|
||||
)
|
||||
|
||||
recognizer_config = OnlineRecognizerConfig(
|
||||
|
||||
Reference in New Issue
Block a user