コード例 #1
0
def main():
    args = parse_args()
    vocoder = MelVocoder(args.load_path)

    args.save_path.mkdir(exist_ok=True, parents=True)

    for i, fname in tqdm(enumerate(args.folder.glob("*.wav"))):
        wavname = fname.name
        wav, sr = librosa.core.load(fname)

        mel, _ = vocoder(torch.from_numpy(wav)[None])
        recons = vocoder.inverse(mel).squeeze().cpu().numpy()

        librosa.output.write_wav(args.save_path / wavname, recons, sr=sr)
def main():
    args = parse_args()
    vocoder = MelVocoder(args.load_path)

    args.save_path.mkdir(exist_ok=True, parents=True)
    
    for i, fname in tqdm(enumerate(args.pt_path.glob('*.pt'))):
        wavname = os.path.splitext(fname.name)[0] + '.wav'
        print('fname', fname)
        print('wavname', wavname)
        spectrogram = torch.load(fname)
        if (len(spectrogram.shape) == 2):
            spectrogram = spectrogram.unsqueeze(0)
        reconstruction = vocoder.inverse(spectrogram).squeeze().cpu().numpy()
        librosa.output.write_wav(str(args.save_path) + '/' + wavname, reconstruction, sr=22050)
コード例 #3
0
ファイル: hubconf.py プロジェクト: NoaKafka/melGAN_FPN
def load_melgan(model_name="multi_speaker"):
    """
    Exposes a MelVocoder Interface
    Args:
        model_name (str): Supports only 2 models, 'linda_johnson' or 'multi_speaker'
    Returns:
        object (MelVocoder):  MelVocoder class.
            Default function (___call__) converts raw audio to mel
            inverse function convert mel to raw audio using MelGAN
    """

    return MelVocoder(path=None, github=True, model_name=model_name)