Ejemplo n.º 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
Ejemplo n.º 2
0
    decisions, _ = gmm_sv_model.make_decisions(illegal_audio_list,
                                               n_jobs=n_jobs,
                                               debug=debug)
    decisions = np.array(decisions)
    far_cnt += np.argwhere(decisions == 1).flatten().size

    untarget_cnt += len(illegal_audio_list)

print(
    "----- Test of gmm-ubm-based SV, result ---> FRR: %d/%d, %f, FAR: %d/%d, %f"
    % (frr_cnt, target_cnt, frr_cnt * 100 / target_cnt, far_cnt, untarget_cnt,
       far_cnt * 100 / untarget_cnt))
''' Test for ivector-PLDA-based OSI
'''
group_id = "test-iv-OSI"
iv_osi_model = iv_OSI(group_id, iv_model_list)
spk_ids = np.array(iv_osi_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)