Exemple #1
0
    def __getitem__(self, idx):
        i, src_fn = self.data[idx]
        src_wav = get_wav(src_fn)
        src_mel = self._to_mel(src_wav)
        if self.indices is None:
            return src_mel, src_mel

        _, tgt_fn = self.data[random.choice(self.indices[i])]
        tgt_wav = get_wav(tgt_fn)
        tgt_mel = self._to_mel(tgt_wav)
        return src_mel, tgt_mel
Exemple #2
0
def f(fpath):
    w, q = get_wav(fpath)
    fname = os.path.basename(fpath).replace('wav', 'npy')
    if not os.path.exists("/data/private/speech/vctk/wavs"):
        os.makedirs("/data/private/speech/vctk/wavs")
    if not os.path.exists("/data/private/speech/vctk/qts"):
        os.makedirs("/data/private/speech/vctk/qts")
    np.save("/data/private/speech/vctk/wavs/{}".format(fname), w)
    np.save("/data/private/speech/vctk/qts/{}".format(fname), q)
Exemple #3
0
def process_one(fn, data_type, wav2vec=None, wav2mel=None):
    if data_type == DataType.NORMAL:
        wav = get_wav(fn)
        return wav
    elif data_type == DataType.WORLD:
        f0, sp, ap = get_world_features(fn)
        return f0, sp, ap
    elif data_type == DataType.WAV2VEC:
        feat, mel = get_wav2vec_features(fn, wav2vec, wav2mel)
        return feat, mel
    else:
        raise ValueError('Invalid value: type of data_type must be DataType')
Exemple #4
0
 def __getitem__(self, idx):
     fn = self.data[idx]
     wav = get_wav(fn)
     mel = self._to_mel(wav)
     return wav, mel
Exemple #5
0
def f(fpath):
    w, q = get_wav(fpath)
    fname = os.path.basename(fpath).replace('wav', 'npy')
    np.save(hp.transformed_data_wav + "/{}".format(fname), w)
    np.save(hp.transformed_data_qts + "/{}".format(fname), q)
Exemple #6
0
    parser.add_argument('--src_path', type=str, required=True)
    parser.add_argument('--tgt_path', type=str, required=True)
    parser.add_argument('--config_path', type=str, required=True)
    parser.add_argument('--ckpt_path', type=str, required=True)
    parser.add_argument('--output_dir', type=str, default='./outputs')
    args = parser.parse_args()

    params = get_config(args.config_path)

    output_dir = pathlib.Path(args.output_dir) / args.ckpt_path.split('/')[-2]

    if not output_dir.exists():
        output_dir.mkdir(parents=True)

    print('Build model')
    model = module_from_config(params)
    model = model.load_from_checkpoint(args.ckpt_path)
    model.freeze()

    print(model.hparams)

    print('Inference')
    wav = model(args.src_path, args.tgt_path)

    print('Saving')
    src_wav, tgt_wav = get_wav(args.src_path), get_wav(args.tgt_path)
    save_sample(str(output_dir / 'src.wav'), src_wav)
    save_sample(str(output_dir / 'tgt.wav'), tgt_wav)
    save_sample(str(output_dir / 'gen.wav'), wav)
    print('End')