def get_dataset(self, dsname): if dsname not in self.list_datasets(): raise KaldiError( f'Tried to load a dataset called "{dsname}" that does not exist' ) hash_dir = self.config['datasets'][dsname] return Dataset.load(self.datasets_path.joinpath(hash_dir))
def get_transcription(self, tname): if tname not in self.list_transcriptions(): raise KaldiError(f'Tried to load a transcription called "{tname}" that does not exist') hash_dir = self.config['transcriptions'][tname] t = Transcription.load(self.transcriptions_path.joinpath(hash_dir)) t.model = self.get_model(t.config['model_name']) return t
def get_pron_dict(self, pdname): if pdname not in self.list_pron_dicts(): raise KaldiError(f'Tried to load a pron dict called "{pdname}" that does not exist') hash_dir = self.config['pron_dicts'][pdname] pd = PronDict.load(self.pron_dicts_path.joinpath(hash_dir)) pd.dataset = self.get_dataset(pd.config['dataset_name']) return pd
def get_model(self, mname): if mname not in self.list_models(): raise KaldiError(f'Tried to load a model called "{mname}" that does not exist') hash_dir = self.config['models'][mname] m = Model.load(self.models_path.joinpath(hash_dir)) m.dataset = self.get_dataset(m.config['dataset_name']) m.pron_dict = self.get_pron_dict(m.config['pron_dict_name']) return m
def new_dataset(self, dsname): existing_names = self.list_datasets() if dsname in self.config['datasets'].keys(): raise KaldiError( f'Tried adding \'{dsname}\' which is already in {existing_names} with hash {self.config["datasets"][dsname]}.', human_message=f'data set with name "{dsname}" already exists' ) ds = Dataset(parent_path=self.datasets_path, name=dsname, logger=self.logger) datasets = self.config['datasets'] datasets[dsname] = ds.hash self.config['datasets'] = datasets return ds