Example #1
0
    def __init__(self, model_dir, tmp_dir, auto_add_to_user_lexicon=None, allow_online_pronunciations=None, lazy_compilation=None, **kwargs):
        CompilerBase.__init__(self)
        KaldiAGCompiler.__init__(self, model_dir=model_dir, tmp_dir=tmp_dir, **kwargs)

        self.auto_add_to_user_lexicon = bool(auto_add_to_user_lexicon)
        self.allow_online_pronunciations = bool(allow_online_pronunciations)
        self.lazy_compilation = bool(lazy_compilation)

        self.kaldi_rule_by_rule_dict = collections.OrderedDict()  # Rule -> KaldiRule
        # self._grammar_rule_states_dict = dict()  # FIXME: disabled!
        self.kaldi_rules_by_listreflist_dict = collections.defaultdict(set)  # Rule -> Set[KaldiRule]
        self.internal_grammar = InternalGrammar('!kaldi_engine_internal')
Example #2
0
    def __init__(self,
                 model_dir,
                 tmp_dir,
                 auto_add_to_user_lexicon=None,
                 **kwargs):
        CompilerBase.__init__(self)
        KaldiAGCompiler.__init__(self, model_dir, tmp_dir=tmp_dir, **kwargs)

        self.auto_add_to_user_lexicon = auto_add_to_user_lexicon

        self.kaldi_rule_by_rule_dict = collections.OrderedDict(
        )  # maps Rule -> KaldiRule
        self._grammar_rule_states_dict = dict()  # FIXME: disabled!
        self.kaldi_rules_by_listreflist_dict = collections.defaultdict(set)
        self.added_word = False
        self.internal_grammar = InternalGrammar('!kaldi_engine_internal')