MCPcopy Index your code
hub / github.com/MoonInTheRiver/DiffSinger / forward

Method forward

modules/parallel_wavegan/models/source.py:216–243  ·  view source on GitHub ↗

output = forward(signal, system_ir) signal: (batchsize, length1, dim) system_ir: (length2, dim) output: (batchsize, length1, dim)

(self, signal, system_ir)

Source from the content-addressed store, hash-verified

214 super(SignalsConv1d, self).__init__()
215
216 def forward(self, signal, system_ir):
217 """ output = forward(signal, system_ir)
218
219 signal: (batchsize, length1, dim)
220 system_ir: (length2, dim)
221
222 output: (batchsize, length1, dim)
223 """
224 if signal.shape[-1] != system_ir.shape[-1]:
225 print("Error: SignalsConv1d expects shape:")
226 print("signal (batchsize, length1, dim)")
227 print("system_id (batchsize, length2, dim)")
228 print("But received signal: {:s}".format(str(signal.shape)))
229 print(" system_ir: {:s}".format(str(system_ir.shape)))
230 sys.exit(1)
231 padding_length = system_ir.shape[0] - 1
232 groups = signal.shape[-1]
233
234 # pad signal on the left
235 signal_pad = torch_nn_func.pad(signal.permute(0, 2, 1), \
236 (padding_length, 0))
237 # prepare system impulse response as (dim, 1, length2)
238 # also flip the impulse response
239 ir = torch.flip(system_ir.unsqueeze(1).permute(2, 1, 0), \
240 dims=[2])
241 # convolute
242 output = torch_nn_func.conv1d(signal_pad, ir, groups=groups)
243 return output.permute(0, 2, 1)
244
245
246class CyclicNoiseGen_v1(torch.nn.Module):

Callers

nothing calls this directly

Calls 1

padMethod · 0.80

Tested by

no test coverage detected