Esempio n. 1
0
    checkpoint_path = args["<checkpoint>"]
    text_list_file_path = args["<text_list_file>"]
    dst_dir = args["<dst_dir>"]
    max_decoder_steps = int(args["--max-decoder-steps"])
    file_name_suffix = args["--file-name-suffix"]

    checkpoint = torch.load(checkpoint_path)
    checkpoints_dir = os.path.dirname(checkpoint_path)
    with open(checkpoints_dir + '/ids_phones.json') as f:
        phids = json.load(f)

    model = Tacotron(
        n_vocab=len(phids) + 1,
        embedding_dim=256,
        mel_dim=hparams.num_mels,
        linear_dim=hparams.num_freq,
        r=hparams.outputs_per_step,
        padding_idx=hparams.padding_idx,
        use_memory_mask=hparams.use_memory_mask,
    )
    checkpoint = torch.load(checkpoint_path)
    checkpoints_dir = os.path.dirname(checkpoint_path)
    with open(checkpoints_dir + '/ids_phones.json') as f:
        phids = json.load(f)
    phids = dict(phids)

    model.load_state_dict(checkpoint["state_dict"])
    model.decoder.max_decoder_steps = max_decoder_steps

    os.makedirs(dst_dir, exist_ok=True)
Esempio n. 2
0
        collate_fn=collate_fn, pin_memory=hparams.pin_memory)

    exp_name = os.path.basename(exp_dir)
    if use_assistant:
      assistant = RemoteTracker(exp_name, projects_dir='Arabic', 
                                upload_source_files=[os.getcwd() + '/' + 'conf/arabic.conf', 
                                                     os.getcwd() + '/local/model.py',
                                                     os.getcwd() + '/local/train_phones.py'])
    else:
      assistant = None

    # Model
    model = Tacotron(n_vocab=1+ len(ph_ids),
                     embedding_dim=256,
                     mel_dim=hparams.num_mels,
                     linear_dim=hparams.num_freq,
                     r=hparams.outputs_per_step,
                     padding_idx=hparams.padding_idx,
                     use_memory_mask=hparams.use_memory_mask,
                     )
    model = model.cuda()
    #model = DataParallelFix(model)

    optimizer = optim.Adam(model.parameters(),
                           lr=hparams.initial_learning_rate, betas=(
                               hparams.adam_beta1, hparams.adam_beta2),
                           weight_decay=hparams.weight_decay)

    # Load checkpoint
    if checkpoint_path:
        print("Load checkpoint from: {}".format(checkpoint_path))
        checkpoint = torch.load(checkpoint_path)
    file_name_suffix = args["--file-name-suffix"]

    checkpoint_acousticmodel = torch.load(checkpoint_path_acousticmodel)
    checkpoint_vocoder = torch.load(checkpoint_path_vocoder)

    checkpoints_dir = os.path.dirname(checkpoint_path_acousticmodel)

    with open(checkpoints_dir + '/ids_phones.json') as f:
        phids = json.load(f)
    phids = dict(phids)

    acousticmodel = Tacotron(
        n_vocab=len(phids) + 1,
        embedding_dim=256,
        mel_dim=hparams.num_mels,
        linear_dim=hparams.num_freq,
        r=hparams.outputs_per_step,
        padding_idx=hparams.padding_idx,
        use_memory_mask=hparams.use_memory_mask,
    )

    vocoder_model = WaveLSTM(
        n_vocab=257,
        embedding_dim=256,
        mel_dim=hparams.num_mels,
        linear_dim=hparams.num_freq,
        r=hparams.outputs_per_step,
        padding_idx=hparams.padding_idx,
        use_memory_mask=hparams.use_memory_mask,
    )