from vocoder.models.fatchord_version import WaveRNN from vocoder.audio import * def gen_devset(model: WaveRNN, dev_set, samples, batched, target, overlap, save_path): k = model.get_step() // 1000 for i, (m, x) in enumerate(dev_set, 1): if i > samples: break print('\n| Generating: %i/%i' % (i, samples)) x = x[0].numpy() bits = 16 if hp.voc_mode == 'MOL' else hp.bits if hp.mu_law and hp.voc_mode != 'MOL' : x = decode_mu_law(x, 2**bits, from_labels=True) else : x = label_2_float(x, bits) save_wav(x, save_path.joinpath("%dk_steps_%d_target.wav" % (k, i))) batch_str = "gen_batched_target%d_overlap%d" % (target, overlap) if batched else \ "gen_not_batched" save_str = save_path.joinpath("%dk_steps_%d_%s.wav" % (k, i, batch_str)) wav = model.generate(m, batched, target, overlap, hp.mu_law) save_wav(wav, save_str)