Esempio n. 1
0
    speaker,
    start_flag,
    args.num_samples,
    raw_audio=raw_audio)

model = Model(cost)
model.set_parameter_values(parameters)

print "Successfully loaded the parameters."

if args.sample_one_step:
    gen_x, gen_k, gen_w, gen_pi, gen_phi, gen_pi_att = \
        parrot.sample_using_input(data_tr, args.num_samples)
else:
    gen_x, gen_k, gen_w, gen_pi, gen_phi, gen_pi_att = parrot.sample_model(
        labels_tr, labels_mask_tr, features_mask_tr, speaker_tr,
        args.num_samples, args.num_steps)

print "Successfully sampled the parrot."

gen_x = gen_x.swapaxes(0, 1)
gen_phi = gen_phi.swapaxes(0, 1)

features_lengths = []
labels_lengths = []
for idx in range(args.num_samples):
    # Heuristic for deciding when to end the sampling.
    this_phi = gen_phi[idx]
    this_labels_length = int(labels_mask_tr[idx].sum())

    try:
Esempio n. 2
0
    latent_var_tr_old = numpy.tile(latent_var_tr_old, (args.num_samples, 1))

    for i in range(10000):
        lr_ = numpy.float32(0.001 / (1 + 3 * (i // 1000)))
        cost_ = embed_learn_fn(features_tr, features_mask_tr, labels_tr,
                               labels_mask_tr, new_speakers_tr, 1., lr_)
        costs.append(cost_)
        if (i % 200) == 0:
            # import ipdb; ipdb.set_trace()
            # test_stream = parrot_stream(
            #     args.new_dataset, False, ('test',), args.num_samples,
            #     10000, sorting_mult=1, labels_type=saved_args.labels_type,
            #     quantize_features=saved_args.quantized_input)

            gen_x, gen_k, gen_w, gen_pi, gen_phi, gen_pi_att = parrot.sample_model(
                labels_tr_old, labels_mask_tr_old, features_mask_tr_old,
                new_speakers_tr_old, latent_var_tr_old,
                LATENT_NUM * args.num_samples)

            for j, this_sample in enumerate(gen_x.swapaxes(1, 0)):
                this_sample = this_sample[:int(
                    features_mask_tr_old.sum(axis=0)[j])]
                generate_wav(this_sample,
                             os.path.join(args.save_dir, 'samples',
                                          'adaptation'),
                             "sample_{}_{}_iters_{}".format(
                                 args.samples_name, j, i),
                             sptk_dir=args.sptk_dir,
                             world_dir=args.world_dir,
                             norm_info_file=norm_info_file,
                             do_post_filtering=args.do_post_filtering)
            if len(costs) != 0: