Example #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
Example #2
0
    spk_dir = os.path.join(illegal_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)
        illegal_audio_list.append(audio)

frr_cnt = 0
target_cnt = 0
far_cnt = 0
untarget_cnt = 0
for model in iv_model_list:

    spk_id = model[0]
    spk_id_extra = "test-iv-SV-" + spk_id
    iv_sv_model = iv_SV(spk_id_extra, model)

    audio_list = []
    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)

    target_cnt += len(audio_list)

    decisions, _ = iv_sv_model.make_decisions(audio_list,
                                              n_jobs=n_jobs,
                                              debug=debug)
    decisions = np.array(decisions)