Commit 20c57790 authored by Accraze's avatar Accraze
Browse files

Update generator.py

parent 3e70d83e
......@@ -2,20 +2,22 @@ from magenta.models.nsynth import utils
from magenta.models.nsynth.wavenet import fastgen
def load_encoding(fname, sample_length=None, sr=16000, ckpt='model.ckpt-200000'):
def load_encoding(fname, sample_length=None, sr=16000, ckpt='wavenet-ckpt/model.ckpt-200000'):
# load the audio file
audio = utils.load_audio(fname, sample_length=sample_length, sr=sr)
# encode
# encode audio
encoding = fastgen.encode(audio, ckpt, sample_length)
return audio, encoding
def synthesize():
# wav file from https://commons.wikimedia.org/wiki/File:Drum_(avk).wav
fname = 'Drum_(avk).wav'
sample_length = 1000
audio, encoding = load_encoding(fname, sample_length=sample_length)
fastgen.synthesize(encoding, save_paths=['new-audio.wav'], samples_per_save=sample_length)
ckpt = 'wavenet-ckpt/model.ckpt-200000'
sample_length = 100000
audio, encoding = load_encoding(fname, sample_length=sample_length, ckpt=ckpt)
print('lets synthesize!!!')
fastgen.synthesize(encoding, save_paths=['new-audio.wav'], checkpoint_path=ckpt, samples_per_save=sample_length)
if __name__ == "__main__":
synthesize()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment