def __init__(self, input_stream, output_stream, flags_stream, phone_map_fname, tmp_dir, batch_size): self.phone_map = read_phone_map(phone_map_fname) input_it = kio.read_mat_ark(input_stream) output_dict = {k: v for k, v in kio.read_ali_ark(output_stream)} self.flags_dict = {k: v for k, v in kio.read_vec_int_ark(flags_stream)} self.flags = None gi.DataLoader.__init__(self, input_it, output_dict, tmp_dir, batch_size)
parser.add_argument('feats') parser.add_argument('phones') parser.add_argument('flags') parser.add_argument('exp_dir') parser.add_argument('eval_dir') args = parser.parse_args() os.makedirs(args.eval_dir, exist_ok=True) model_fname = os.path.join(args.exp_dir, 'final.h5') phn_map_fname = os.path.join(args.exp_dir, 'phn_sil_to_idx.int') score_fname = os.path.join(args.eval_dir, 'score.ark') score_txt_fname = os.path.join(args.eval_dir, 'score.txt') score_txt = open(score_txt_fname, 'w') # Load phone map phn_map = read_phone_map(phn_map_fname) # Load kaldi files flags_dict = {k: v for k, v in kio.read_vec_int_ark(args.flags)} ali_dict = {k: v for k, v in kio.read_ali_ark(args.phones)} feats_it = kio.read_mat_ark(args.feats) # Load classifier model model = MispModel.load(model_fname) with open(score_fname, 'wb') as f: for utt, feats in feats_it: # Workaround to deal with missing alignments if utt not in ali_dict: continue
def __init__(self, phone_map_fname, pfeats_lang): self.__dict__ = globals()[pfeats_lang] self.phone_map = read_phone_map(phone_map_fname) self.pfeats_tbl = np.array(self.table, dtype=np.int)