Exemplo n.º 1
0
#####################################################################
parser = argparse.ArgumentParser()
parser.add_argument("--data_dir", default="data/timit/test", type=str)
parser.add_argument("--si_dir", default="model/gru_wsj", type=str)
parser.add_argument("--sa_dir", default="", type=str)
args = parser.parse_args()
#####################################################################
data_dir = args.data_dir
si_dir = args.si_dir
sa_dir = args.sa_dir
#####################################################################
loss_per = 0

os.system("mkdir -p " + si_dir + "/decode")
# data
test_feat = read_feat(data_dir + "/feats.ark", utt_cmvn=True, delta=True)
test_utts = list(test_feat.keys())
test_utts.sort()

# prior
with open(si_dir + "/prior.pk", 'rb') as f:
    prior = pk.load(f)
    print(len(prior))
    prior = np.log(prior).reshape(-1, len(prior))

# dnn
dnn_am = torch.load(si_dir + "/init.pt")
dnn_am.load_state_dict(torch.load(si_dir + "/final.pt"))
dnn_am.cuda()
dnn_am.eval()
if sa_dir is not "":
Exemplo n.º 2
0
model_dir = args.model_dir
loss_per = args.loss_per
#####################################################################
epochs = 1000
batch_size = 64
lr_g = 0.0002
lr_d = 0.0001

change_epoch = 200
save_per_epoch = 5
adv_coef = 1.0; cyc_coef = 10.0; id_coef = 5.0
#####################################################################
torch.cuda.empty_cache()
os.system("mkdir -p "+ model_dir +"/parm")

adapt_storage = read_feat(adapt_dir+"/feats.ark", delta=True, utt_cmvn=True)
dev_storage = read_feat(dev_dir+"/feats.ark", delta=True, utt_cmvn=True)
wide_storage = read_feat(wide_dir+"/feats.ark", delta=True, utt_cmvn=True)

adapt_set = pp.make_cnn_dataset(adapt_storage, input_size=128, step_size=64); print(len(adapt_set))
dev_set = pp.make_cnn_dataset(dev_storage, input_size=128, step_size=64); print(len(dev_set))
wide_set = pp.make_cnn_dataset(wide_storage, input_size=128, step_size=64); print(len(wide_set))

adapt_loader = DataLoader(adapt_set, batch_size=batch_size, shuffle=True)
dev_loader = DataLoader(dev_set, batch_size=batch_size)
wide_loader = DataLoader(wide_set, batch_size=batch_size, shuffle=True)

Gn2w = net.Generator_CNN(feat_dim=120)
Gw2n = net.Generator_CNN(feat_dim=120)
Dn = net.Discriminator_CNN(feat_dim=120, hidden_dim=512)
Dw = net.Discriminator_CNN(feat_dim=120, hidden_dim=512)
Exemplo n.º 3
0
train_feat_dir = args.train_feat_dir
train_ali_dir = args.train_ali_dir
dev_feat_dir = args.dev_feat_dir
dev_ali_dir = args.dev_ali_dir
si_dir = args.si_dir
sa_dir = args.sa_dir
resi_dir = args.resi_dir
#####################################################################
epochs = 24
lr = 0.0001
#####################################################################

os.system("mkdir -p " + resi_dir + "/parm")
os.system("mkdir -p " + resi_dir + "/opt")

train_feat = read_feat(train_feat_dir + "/feats.ark", cmvn=True, delta=True)
dev_feat = read_feat(dev_feat_dir + "/feats.ark", cmvn=True, delta=True)
train_ali = read_ali(train_ali_dir + "/ali.*.gz", train_ali_dir + "/final.mdl")
dev_ali = read_ali(dev_ali_dir + "/ali.*.gz", dev_ali_dir + "/final.mdl")
train_utt = list(train_feat.keys())
dev_utt = list(dev_feat.keys())
train_ivecs = read_vec(train_feat_dir + "/ivectors.ark")
dev_ivecs = read_vec(dev_feat_dir + "/ivectors.ark")

model_sa = torch.load(sa_dir + "/init.pt")
model_sa.load_state_dict(torch.load(sa_dir + "/final.pt"))
model_sa.cuda()

# get normalized feat
print("Feature generation start")
dset_dict = {"train": train_feat, "dev": dev_feat}
Exemplo n.º 4
0
lr_g = 0.00002
lr_d = 0.00001

change_epoch = 2000
save_per_epoch = 5

adv_coef = 1.0
spk_coef = 3.0
cyc_coef = 10.0
con_coef = 1.0
norm_coef = 0.01
#####################################################################
torch.cuda.empty_cache()
os.system("mkdir -p " + model_dir + "/parm")

train_storage = read_feat(train_dir + "/feats.ark", cmvn=True, delta=True)
dev_storage = read_feat(dev_dir + "/feats.ark", cmvn=True, delta=True)

# read ivector into {spk_id:ivector}
train_ivecs = read_vec(train_dir + "/ivectors.ark")
dev_ivecs = read_vec(dev_dir + "/ivectors.ark")

# {spk_id:[segment(128*120)1, seg2, seg3, ...]}
train_segs = pp.make_spk_cnn_set(train_storage,
                                 frame_size=frame_size,
                                 step_size=step_size)
print(len(train_segs))
dev_segs = pp.make_spk_cnn_set(dev_storage,
                               frame_size=frame_size,
                               step_size=step_size)
print(len(dev_segs))
Exemplo n.º 5
0
train_feat_dir = args.train_feat_dir
train_ali_dir = args.train_ali_dir
dev_feat_dir = args.dev_feat_dir
dev_ali_dir = args.dev_ali_dir
model_dir = args.model_dir
#####################################################################
epochs = 30
batch_size = 1
lr = 0.0001
pdf_num = 5626  # 1920(timit tri3) 5626(ntimit NB) 5657(ntimit WB)
#####################################################################
os.system("mkdir -p " + model_dir + "/parm")
os.system("mkdir -p " + model_dir + "/opt")

train_feat = read_feat(train_feat_dir + "/feats.ark",
                       utt_cmvn=False,
                       delta=True)
dev_feat = read_feat(dev_feat_dir + "/feats.ark", utt_cmvn=False, delta=True)

train_ali = read_ali(train_ali_dir + "/ali.*.gz", train_ali_dir + "/final.mdl")
dev_ali = read_ali(dev_ali_dir + "/ali.*.gz", dev_ali_dir + "/final.mdl")

train_utt = list(train_feat.keys())
dev_utt = list(dev_feat.keys())

model = net.GRU_HMM(input_dim=120,
                    hidden_dim=512,
                    num_layers=5,
                    dropout=0.3,
                    output_dim=pdf_num)
torch.save(model, model_dir + "/init.pt")
Exemplo n.º 6
0
parser.add_argument("--size", default=1, type=int)
args = parser.parse_args()
#####################################################################
adapt_dir = args.adapt_dir
dev_dir = args.dev_dir
si_dir = args.si_dir
sa_dir = args.sa_dir
#####################################################################
epochs = 50
lr = 0.00002
#####################################################################

#####################################################################
os.system("mkdir -p " + sa_dir + "/parm")

adapt_feat = read_feat(adapt_dir + "/feats.ark", delta=True)
dev_feat = read_feat(dev_dir + "/feats.ark", delta=True)

adapt_utt = list(adapt_feat.keys())
dev_utt = list(dev_feat.keys())

for dataset in [adapt_feat, dev_feat]:
    for utt_id, feat_mat in dataset.items():
        feat_mat = pp.matrix_normalize(feat_mat, axis=1, fcn_type="mean")
        feat_mat = torch.Tensor(feat_mat).cuda().float()
        dataset[utt_id] = feat_mat

model_si = torch.load(si_dir + "/init.pt")
model_si.load_state_dict(torch.load(si_dir + "/final.pt"))
model_si.cuda()
model_si.eval()
Exemplo n.º 7
0
change_epoch = 200
save_per_epoch = 5
adv_coef = 1.0
cyc_coef = 10.0
id_coef = 5.0

utt_cmvn = False
spk_cmvn = False
delta = True
#####################################################################
torch.cuda.empty_cache()
os.system("mkdir -p " + model_dir + "/parm")

adapt_storage = read_feat(adapt_dir + "/feats.ark",
                          utt_cmvn=utt_cmvn,
                          spk_cmvn=spk_cmvn,
                          delta=delta)
dev_storage = read_feat(dev_dir + "/feats.ark",
                        utt_cmvn=utt_cmvn,
                        spk_cmvn=spk_cmvn,
                        delta=delta)
target_storage = read_feat(target_dir + "/feats.ark",
                           utt_cmvn=utt_cmvn,
                           spk_cmvn=spk_cmvn,
                           delta=delta)

adapt_lab = read_vec(adapt_dir + "/packet.ark")
dev_lab = read_vec(dev_dir + "/packet.ark")

adapt_set = pp.make_cnn_dataset_and_lab(adapt_storage,
                                        adapt_lab,