MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / _forward

Method _forward

modules/fastspeech/tts_modules.py:106–120  ·  view source on GitHub ↗
(self, xs, x_masks=None, is_inference=False)

Source from the content-addressed store, hash-verified

104 self.linear = torch.nn.Linear(n_chans, odims)
105
106 def _forward(self, xs, x_masks=None, is_inference=False):
107 xs = xs.transpose(1, -1) # (B, idim, Tmax)
108 for f in self.conv:
109 xs = f(xs) # (B, C, Tmax)
110 if x_masks is not None:
111 xs = xs * (1 - x_masks.float())[:, None, :]
112
113 xs = self.linear(xs.transpose(1, -1)) # [B, T, C]
114 xs = xs * (1 - x_masks.float())[:, :, None] # (B, T, C)
115 if is_inference:
116 return self.out2dur(xs), xs
117 else:
118 if hparams['dur_loss'] in ['mse']:
119 xs = xs.squeeze(-1) # (B, Tmax)
120 return xs
121
122 def out2dur(self, xs):
123 if hparams['dur_loss'] in ['mse']:

Callers 2

forwardMethod · 0.95
inferenceMethod · 0.95

Calls 1

out2durMethod · 0.95

Tested by

no test coverage detected