Beispiel #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
Beispiel #2
0
decisions, _ = iv_osi_model.make_decisions(illegal_audio_list,
                                           debug=debug,
                                           n_jobs=n_jobs)
decisions = np.array(decisions)
far_cnt = np.argwhere(decisions == 1).flatten().size

print(
    "----- Test of ivector-PLDA-based OSI, result ---> FRR: %d/%d, %f, IER: %d/%d, %f, FAR: %d/%d, %f -----"
    % (frr_cnt, target_cnt, frr_cnt * 100 / target_cnt, ier_cnt, target_cnt,
       ier_cnt * 100 / target_cnt, far_cnt, untarget_cnt,
       far_cnt * 100 / untarget_cnt))
''' Test for gmm-ubm-based OSI
'''
group_id = "test-gmm-OSI"
gmm_osi_model = gmm_OSI(group_id, gmm_model_list, ubm)
spk_ids = np.array(gmm_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)