예제 #1
0
def load_model(spk_id_list, architecture, task, threshold, id):

    iv_model_paths = [
        os.path.join(model_dir, spk_id + ".iv") for spk_id in spk_id_list
    ]
    gmm_model_paths = [
        os.path.join(model_dir, spk_id + ".gmm") for spk_id in spk_id_list
    ]

    iv_model_list = []
    gmm_model_list = []

    for path in iv_model_paths:
        with open(path, "rb") as reader:
            model = pickle.load(reader)
            iv_model_list.append(model)
    for path in gmm_model_paths:
        with open(path, "rb") as reader:
            model = pickle.load(reader)
            gmm_model_list.append(model)

    ubm = os.path.join(pre_model_dir, "final.dubm")

    if architecture == IV:

        if task == OSI:

            model = iv_OSI(id, iv_model_list, threshold=threshold)

        elif task == CSI:

            model = iv_CSI(id, iv_model_list)

        else:

            model = iv_SV(id, iv_model_list[0], threshold=threshold)

    else:

        if task == OSI:

            model = gmm_OSI(id, gmm_model_list, ubm, threshold=threshold)

        elif task == CSI:

            model = gmm_CSI(id, gmm_model_list)

        else:

            model = gmm_SV(id, gmm_model_list[0], ubm, threshold=threshold)

    return model
예제 #2
0
        target_label_list.append(target_label)

decisions, _ = iv_csi_model.make_decisions(audio_list,
                                           debug=debug,
                                           n_jobs=n_jobs)
decisions = np.array(decisions)
target_label_list = np.array(target_label_list)
correct_cnt = np.argwhere(decisions == target_label_list).flatten().size
acc = correct_cnt * 100 / decisions.size
print(
    "----- Test of ivector-PLDA-based CSI, result ---> %d/%d, Accuracy:%f ----- "
    % (correct_cnt, decisions.size, acc)),
''' Test for gmm-ubm-based CSI
'''
group_id = "test-gmm-CSI"
gmm_csi_model = gmm_CSI(group_id, gmm_model_list)
spk_ids = np.array(gmm_csi_model.spk_ids)

audio_list = []
target_label_list = []
spk_iter = os.listdir(test_dir)
for spk_id in spk_iter:

    target_label = np.argwhere(spk_ids == spk_id).flatten()[0]

    spk_dir = os.path.join(test_dir, spk_id)
    audio_iter = os.listdir(spk_dir)
    for i, audio_name in enumerate(audio_iter):
        path = os.path.join(spk_dir, audio_name)
        _, audio = read(path)
        audio_list.append(audio)