Skip to content

Discriminator

Discriminator

Bases: Module

Discriminator for the UnuvNet vocoder.

This class implements a discriminator that consists of a MultiResolutionDiscriminator and a MultiPeriodDiscriminator.

Parameters:

Name Type Description Default
model_config VocoderModelConfig

Model configuration object.

required

Attributes:

Name Type Description
MRD MultiResolutionDiscriminator

Multi-resolution discriminator instance.

MPD MultiPeriodDiscriminator

Multi-period discriminator instance.

Methods:

Name Description
forward

Computes the forward pass of the discriminator.

Source code in models/vocoder/univnet/discriminator.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Discriminator(Module):
    r"""Discriminator for the UnuvNet vocoder.

    This class implements a discriminator that consists of a `MultiResolutionDiscriminator` and a `MultiPeriodDiscriminator`.

    Args:
        model_config (VocoderModelConfig): Model configuration object.

    Attributes:
        MRD (MultiResolutionDiscriminator): Multi-resolution discriminator instance.
        MPD (MultiPeriodDiscriminator): Multi-period discriminator instance.

    Methods:
        forward(x): Computes the forward pass of the discriminator.

    """

    def __init__(self, model_config: VocoderModelConfig):
        super().__init__()
        self.MRD = MultiResolutionDiscriminator(model_config=model_config)
        self.MPD = MultiPeriodDiscriminator(model_config=model_config)

    def forward(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
        r"""Computes the forward pass of the discriminator.

        Args:
            x (torch.Tensor): Input tensor of shape [B, C, T].

        Returns:
            tuple(torch.Tensor, torch.Tensor): Tuple containing the output tensors of the `MultiResolutionDiscriminator` and `MultiPeriodDiscriminator` instances.
        """
        return self.MRD(x), self.MPD(x)

forward(x)

Computes the forward pass of the discriminator.

Parameters:

Name Type Description Default
x Tensor

Input tensor of shape [B, C, T].

required

Returns:

Name Type Description
tuple (Tensor, Tensor)

Tuple containing the output tensors of the MultiResolutionDiscriminator and MultiPeriodDiscriminator instances.

Source code in models/vocoder/univnet/discriminator.py
32
33
34
35
36
37
38
39
40
41
def forward(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
    r"""Computes the forward pass of the discriminator.

    Args:
        x (torch.Tensor): Input tensor of shape [B, C, T].

    Returns:
        tuple(torch.Tensor, torch.Tensor): Tuple containing the output tensors of the `MultiResolutionDiscriminator` and `MultiPeriodDiscriminator` instances.
    """
    return self.MRD(x), self.MPD(x)