Spaces:
Runtime error
Runtime error
Upload vocoder/gen_wavernn.py with huggingface_hub
Browse files- vocoder/gen_wavernn.py +31 -0
vocoder/gen_wavernn.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from vocoder.models.fatchord_version import WaveRNN
|
2 |
+
from vocoder.audio import *
|
3 |
+
|
4 |
+
|
5 |
+
def gen_testset(model: WaveRNN, test_set, samples, batched, target, overlap, save_path):
|
6 |
+
k = model.get_step() // 1000
|
7 |
+
|
8 |
+
for i, (m, x) in enumerate(test_set, 1):
|
9 |
+
if i > samples:
|
10 |
+
break
|
11 |
+
|
12 |
+
print('\n| Generating: %i/%i' % (i, samples))
|
13 |
+
|
14 |
+
x = x[0].numpy()
|
15 |
+
|
16 |
+
bits = 16 if hp.voc_mode == 'MOL' else hp.bits
|
17 |
+
|
18 |
+
if hp.mu_law and hp.voc_mode != 'MOL' :
|
19 |
+
x = decode_mu_law(x, 2**bits, from_labels=True)
|
20 |
+
else :
|
21 |
+
x = label_2_float(x, bits)
|
22 |
+
|
23 |
+
save_wav(x, save_path.joinpath("%dk_steps_%d_target.wav" % (k, i)))
|
24 |
+
|
25 |
+
batch_str = "gen_batched_target%d_overlap%d" % (target, overlap) if batched else \
|
26 |
+
"gen_not_batched"
|
27 |
+
save_str = save_path.joinpath("%dk_steps_%d_%s.wav" % (k, i, batch_str))
|
28 |
+
|
29 |
+
wav = model.generate(m, batched, target, overlap, hp.mu_law)
|
30 |
+
save_wav(wav, save_str)
|
31 |
+
|