MCPcopy Create free account
hub / github.com/MeiGen-AI/MultiTalk / Decoder

Class Decoder

kokoro/istftnet.py:384–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382
383
384class Decoder(nn.Module):
385 def __init__(self, dim_in, style_dim, dim_out,
386 resblock_kernel_sizes,
387 upsample_rates,
388 upsample_initial_channel,
389 resblock_dilation_sizes,
390 upsample_kernel_sizes,
391 gen_istft_n_fft, gen_istft_hop_size,
392 disable_complex=False):
393 super().__init__()
394 self.encode = AdainResBlk1d(dim_in + 2, 1024, style_dim)
395 self.decode = nn.ModuleList()
396 self.decode.append(AdainResBlk1d(1024 + 2 + 64, 1024, style_dim))
397 self.decode.append(AdainResBlk1d(1024 + 2 + 64, 1024, style_dim))
398 self.decode.append(AdainResBlk1d(1024 + 2 + 64, 1024, style_dim))
399 self.decode.append(AdainResBlk1d(1024 + 2 + 64, 512, style_dim, upsample=True))
400 self.F0_conv = weight_norm(nn.Conv1d(1, 1, kernel_size=3, stride=2, groups=1, padding=1))
401 self.N_conv = weight_norm(nn.Conv1d(1, 1, kernel_size=3, stride=2, groups=1, padding=1))
402 self.asr_res = nn.Sequential(weight_norm(nn.Conv1d(512, 64, kernel_size=1)))
403 self.generator = Generator(style_dim, resblock_kernel_sizes, upsample_rates,
404 upsample_initial_channel, resblock_dilation_sizes,
405 upsample_kernel_sizes, gen_istft_n_fft, gen_istft_hop_size, disable_complex=disable_complex)
406
407 def forward(self, asr, F0_curve, N, s):
408 F0 = self.F0_conv(F0_curve.unsqueeze(1))
409 N = self.N_conv(N.unsqueeze(1))
410 x = torch.cat([asr, F0, N], axis=1)
411 x = self.encode(x, s)
412 asr_res = self.asr_res(asr)
413 res = True
414 for block in self.decode:
415 if res:
416 x = torch.cat([x, asr_res, F0, N], axis=1)
417 x = block(x, s)
418 if block.upsample_type != "none":
419 res = False
420 x = self.generator(x, s, F0_curve)
421 return x

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected