Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Args:
group (string): name of the group that we want to create idmap for
NOTE: Duplicated entries are allowed in each list.
"""
assert group in ["enroll", "test"],\
"Invalid group name!! Choose either 'enroll', 'test'"
# Make enrollment (IdMap) file list
group_dir = os.path.join(self.audio_dir, group)
group_files = sorted(os.listdir(group_dir))
# list of model IDs
group_models = [files.split('.')[0] for files in group_files]
# list of audio segments IDs
group_segments = [group+"/"+f for f in group_files]
# Generate IdMap
group_idmap = sidekit.IdMap()
group_idmap.leftids = np.asarray(group_models)
group_idmap.rightids = np.asarray(group_segments)
group_idmap.start = np.empty(group_idmap.rightids.shape, '|O')
group_idmap.stop = np.empty(group_idmap.rightids.shape, '|O')
if group_idmap.validate():
group_idmap.write(os.path.join(self.task_dir, group+'_idmap.h5'))
#generate tv_idmap and plda_idmap as well
if group == "enroll":
group_idmap.write(os.path.join(self.task_dir, 'tv_idmap.h5'))
group_idmap.write(os.path.join(self.task_dir, 'plda_idmap.h5'))
else:
raise RuntimeError('Problems with creating idMap file')
def load_data(self, folder_name, speaker_list):
self.logger.info('load data')
with open(join(get_training('i_vector', folder_name), speaker_list +"_files.txt"), "r") as fh:
ubm_list = np.array([line.rstrip() for line in fh])
with open(join(get_training('i_vector', folder_name), speaker_list +"_ids.txt"), "r") as fh:
id_list = np.array([line.rstrip() for line in fh])
tv_idmap = sidekit.IdMap()
tv_idmap.leftids = id_list
tv_idmap.rightids = ubm_list
tv_idmap.start = np.empty((len(ubm_list)), dtype="|O")
tv_idmap.stop = np.empty((len(ubm_list)), dtype="|O")
return ubm_list, tv_idmap