SourceModuleCycNoise_v1 SourceModule(sampling_rate, noise_std=0.003, voiced_threshod=0) sampling_rate: sampling_rate in Hz noise_std: std of Gaussian noise (default: 0.003) voiced_threshold: threshold to set U/V given F0 (default: 0) cyc, noise, uv = SourceModuleCycNoise_v1(F0
| 442 | |
| 443 | |
| 444 | class SourceModuleCycNoise_v1(torch.nn.Module): |
| 445 | """ SourceModuleCycNoise_v1 |
| 446 | SourceModule(sampling_rate, noise_std=0.003, voiced_threshod=0) |
| 447 | sampling_rate: sampling_rate in Hz |
| 448 | |
| 449 | noise_std: std of Gaussian noise (default: 0.003) |
| 450 | voiced_threshold: threshold to set U/V given F0 (default: 0) |
| 451 | |
| 452 | cyc, noise, uv = SourceModuleCycNoise_v1(F0_upsampled, beta) |
| 453 | F0_upsampled (batchsize, length, 1) |
| 454 | beta (1) |
| 455 | cyc (batchsize, length, 1) |
| 456 | noise (batchsize, length, 1) |
| 457 | uv (batchsize, length, 1) |
| 458 | """ |
| 459 | |
| 460 | def __init__(self, sampling_rate, noise_std=0.003, voiced_threshod=0): |
| 461 | super(SourceModuleCycNoise_v1, self).__init__() |
| 462 | self.sampling_rate = sampling_rate |
| 463 | self.noise_std = noise_std |
| 464 | self.l_cyc_gen = CyclicNoiseGen_v1(sampling_rate, noise_std, |
| 465 | voiced_threshod) |
| 466 | |
| 467 | def forward(self, f0_upsamped, beta): |
| 468 | """ |
| 469 | cyc, noise, uv = SourceModuleCycNoise_v1(F0, beta) |
| 470 | F0_upsampled (batchsize, length, 1) |
| 471 | beta (1) |
| 472 | cyc (batchsize, length, 1) |
| 473 | noise (batchsize, length, 1) |
| 474 | uv (batchsize, length, 1) |
| 475 | """ |
| 476 | # source for harmonic branch |
| 477 | cyc, pulse, sine, uv, add_noi = self.l_cyc_gen(f0_upsamped, beta) |
| 478 | |
| 479 | # source for noise branch, in the same shape as uv |
| 480 | noise = torch.randn_like(uv) * self.noise_std / 3 |
| 481 | return cyc, noise, uv |
| 482 | |
| 483 | |
| 484 | class SourceModuleHnNSF(torch.nn.Module): |