def __init__(self, model, data_descriptions=None, config=None): super().__init__(model, None, None) self.model = model self.hparams = register_and_parse_hparams(self.default_config, config, cls=self.__class__) lm_model = None if self.hparams.lm_type == "rnn": from athena.main import build_model_from_jsonfile _, lm_model, _, lm_checkpointer = build_model_from_jsonfile( self.hparams.lm_path) lm_checkpointer.restore_from_best() if self.hparams.decoder_type == "beam_search_decoder": self.decoder = BeamSearchDecoder.build_decoder( self.hparams, self.model.num_class, self.model.sos, self.model.eos, self.model.time_propagate, lm_model=lm_model) elif self.hparams.decoder_type == "wfst_decoder": self.decoder = WFSTDecoder( self.hparams.wfst_graph, acoustic_scale=self.hparams.acoustic_scale, max_active=self.hparams.max_active, min_active=self.hparams.min_active, beam=self.hparams.wfst_beam, max_seq_len=self.hparams.max_seq_len, sos=self.model.sos, eos=self.model.eos) else: raise ValueError("This decoder type is not supported")
def __init__(self, model, config=None, lm_model=None): super().__init__(model, None, None) self.model = model self.hparams = register_and_parse_hparams(self.default_config, config, cls=self.__class__) if self.hparams.decoder_type == "beam_search_decoder": self.decoder = BeamSearchDecoder.build_decoder( self.hparams, self.model.num_class, self.model.sos, self.model.eos, self.model.time_propagate, lm_model=lm_model) elif self.hparams.decoder_type == "wfst_decoder": self.decoder = WFSTDecoder( self.hparams.wfst_graph, acoustic_scale=self.hparams.acoustic_scale, max_active=self.hparams.max_active, min_active=self.hparams.min_active, beam=self.hparams.wfst_beam, max_seq_len=self.hparams.max_seq_len) else: raise ValueError("This decoder type is not supported")