MCPcopy Create free account
hub / github.com/MYZY-AI/Muyan-TTS / WNEncoder

Class WNEncoder

sovits/models.py:373–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371
372
373class WNEncoder(nn.Module):
374 def __init__(
375 self,
376 in_channels,
377 out_channels,
378 hidden_channels,
379 kernel_size,
380 dilation_rate,
381 n_layers,
382 gin_channels=0,
383 ):
384 super().__init__()
385 self.in_channels = in_channels
386 self.out_channels = out_channels
387 self.hidden_channels = hidden_channels
388 self.kernel_size = kernel_size
389 self.dilation_rate = dilation_rate
390 self.n_layers = n_layers
391 self.gin_channels = gin_channels
392
393 self.pre = nn.Conv1d(in_channels, hidden_channels, 1)
394 self.enc = modules.WN(
395 hidden_channels,
396 kernel_size,
397 dilation_rate,
398 n_layers,
399 gin_channels=gin_channels,
400 )
401 self.proj = nn.Conv1d(hidden_channels, out_channels, 1)
402 self.norm = modules.LayerNorm(out_channels)
403
404 def forward(self, x, x_lengths, g=None):
405 x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(
406 x.dtype
407 )
408 x = self.pre(x) * x_mask
409 x = self.enc(x, x_mask, g=g)
410 out = self.proj(x) * x_mask
411 out = self.norm(out)
412 return out
413
414
415class Generator(torch.nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected