You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1001 B
Python
32 lines
1001 B
Python
4 years ago
|
from vocoder.wavernn.models.fatchord_version import WaveRNN
|
||
|
from vocoder.wavernn.audio import *
|
||
4 years ago
|
|
||
|
|
||
|
def gen_testset(model: WaveRNN, test_set, samples, batched, target, overlap, save_path):
|
||
|
k = model.get_step() // 1000
|
||
|
|
||
|
for i, (m, x) in enumerate(test_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)
|
||
|
|