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

Method forward

kokoro/modules.py:109–122  ·  view source on GitHub ↗
(self, texts, style, text_lengths, alignment, m)

Source from the content-addressed store, hash-verified

107 self.N_proj = nn.Conv1d(d_hid // 2, 1, 1, 1, 0)
108
109 def forward(self, texts, style, text_lengths, alignment, m):
110 d = self.text_encoder(texts, style, text_lengths, m)
111 m = m.unsqueeze(1)
112 lengths = text_lengths if text_lengths.device == torch.device('cpu') else text_lengths.to('cpu')
113 x = nn.utils.rnn.pack_padded_sequence(d, lengths, batch_first=True, enforce_sorted=False)
114 self.lstm.flatten_parameters()
115 x, _ = self.lstm(x)
116 x, _ = nn.utils.rnn.pad_packed_sequence(x, batch_first=True)
117 x_pad = torch.zeros([x.shape[0], m.shape[-1], x.shape[-1]], device=x.device)
118 x_pad[:, :x.shape[1], :] = x
119 x = x_pad
120 duration = self.duration_proj(nn.functional.dropout(x, 0.5, training=False))
121 en = (d.transpose(-1, -2) @ alignment)
122 return duration.squeeze(-1), en
123
124 def F0Ntrain(self, x, s):
125 x, _ = self.shared(x.transpose(-1, -2))

Callers

nothing calls this directly

Calls 1

deviceMethod · 0.80

Tested by

no test coverage detected