paddlespeech.t2s.models.parallel_wavegan.parallel_wavegan module
- class paddlespeech.t2s.models.parallel_wavegan.parallel_wavegan.PWGDiscriminator(in_channels: int = 1, out_channels: int = 1, kernel_size: int = 3, layers: int = 10, conv_channels: int = 64, dilation_factor: int = 1, nonlinear_activation: str = 'leakyrelu', nonlinear_activation_params: Dict[str, Any] = {'negative_slope': 0.2}, bias: bool = True, use_weight_norm: bool = True, init_type: str = 'xavier_uniform')[source]
Bases:
Layer
A convolutional discriminator for audio.
- Args:
- in_channels (int, optional):
Number of channels of the input audio, by default 1
- out_channels (int, optional):
Output feature size, by default 1
- kernel_size (int, optional):
Kernel size of convolutional sublayers, by default 3
- layers (int, optional):
Number of layers, by default 10
- conv_channels (int, optional):
Feature size of the convolutional sublayers, by default 64
- dilation_factor (int, optional):
The factor with which dilation of each convolutional sublayers grows exponentially if it is greater than 1, else the dilation of each convolutional sublayers grows linearly, by default 1
- nonlinear_activation (str, optional):
The activation after each convolutional sublayer, by default "leakyrelu"
- nonlinear_activation_params (Dict[str, Any], optional):
The parameters passed to the activation's initializer, by default {"negative_slope": 0.2}
- bias (bool, optional):
Whether to use bias in convolutional sublayers, by default True
- use_weight_norm (bool, optional):
Whether to use weight normalization at all convolutional sublayers, by default True
Methods
__call__
(*inputs, **kwargs)Call self as a function.
add_parameter
(name, parameter)Adds a Parameter instance.
add_sublayer
(name, sublayer)Adds a sub Layer instance.
apply
(fn)Applies
fn
recursively to every sublayer (as returned by.sublayers()
) as well as self.buffers
([include_sublayers])Returns a list of all buffers from current layer and its sub-layers.
children
()Returns an iterator over immediate children layers.
clear_gradients
()Clear the gradients of all parameters for this layer.
create_parameter
(shape[, attr, dtype, ...])Create parameters for this layer.
create_tensor
([name, persistable, dtype])Create Tensor for this layer.
create_variable
([name, persistable, dtype])Create Tensor for this layer.
eval
()Sets this Layer and all its sublayers to evaluation mode.
extra_repr
()Extra representation of this layer, you can have custom implementation of your own layer.
forward
(x)Args:
full_name
()Full name for this layer, composed by name_scope + "/" + MyLayer.__class__.__name__
load_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
named_buffers
([prefix, include_sublayers])Returns an iterator over all buffers in the Layer, yielding tuple of name and Tensor.
named_children
()Returns an iterator over immediate children layers, yielding both the name of the layer as well as the layer itself.
named_parameters
([prefix, include_sublayers])Returns an iterator over all parameters in the Layer, yielding tuple of name and parameter.
named_sublayers
([prefix, include_self, ...])Returns an iterator over all sublayers in the Layer, yielding tuple of name and sublayer.
parameters
([include_sublayers])Returns a list of all Parameters from current layer and its sub-layers.
register_buffer
(name, tensor[, persistable])Registers a tensor as buffer into the layer.
register_forward_post_hook
(hook)Register a forward post-hook for Layer.
register_forward_pre_hook
(hook)Register a forward pre-hook for Layer.
set_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
set_state_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
state_dict
([destination, include_sublayers, ...])Get all parameters and persistable buffers of current layer and its sub-layers.
sublayers
([include_self])Returns a list of sub layers.
to
([device, dtype, blocking])Cast the parameters and buffers of Layer by the give device, dtype and blocking.
to_static_state_dict
([destination, ...])Get all parameters and buffers of current layer and its sub-layers.
train
()Sets this Layer and all its sublayers to training mode.
apply_weight_norm
backward
register_state_dict_hook
remove_weight_norm
- class paddlespeech.t2s.models.parallel_wavegan.parallel_wavegan.PWGGenerator(in_channels: int = 1, out_channels: int = 1, kernel_size: int = 3, layers: int = 30, stacks: int = 3, residual_channels: int = 64, gate_channels: int = 128, skip_channels: int = 64, aux_channels: int = 80, aux_context_window: int = 2, dropout: float = 0.0, bias: bool = True, use_weight_norm: bool = True, use_causal_conv: bool = False, upsample_scales: List[int] = [4, 4, 4, 4], nonlinear_activation: Optional[str] = None, nonlinear_activation_params: Dict[str, Any] = {}, interpolate_mode: str = 'nearest', freq_axis_kernel_size: int = 1, init_type: str = 'xavier_uniform')[source]
Bases:
Layer
Wave Generator for Parallel WaveGAN
- Args:
- in_channels (int, optional):
Number of channels of the input waveform, by default 1
- out_channels (int, optional):
Number of channels of the output waveform, by default 1
- kernel_size (int, optional):
Kernel size of the residual blocks inside, by default 3
- layers (int, optional):
Number of residual blocks inside, by default 30
- stacks (int, optional):
The number of groups to split the residual blocks into, by default 3 Within each group, the dilation of the residual block grows exponentially.
- residual_channels (int, optional):
Residual channel of the residual blocks, by default 64
- gate_channels (int, optional):
Gate channel of the residual blocks, by default 128
- skip_channels (int, optional):
Skip channel of the residual blocks, by default 64
- aux_channels (int, optional):
Auxiliary channel of the residual blocks, by default 80
- aux_context_window (int, optional):
The context window size of the first convolution applied to the auxiliary input, by default 2
- dropout (float, optional):
Dropout of the residual blocks, by default 0.
- bias (bool, optional):
Whether to use bias in residual blocks, by default True
- use_weight_norm (bool, optional):
Whether to use weight norm in all convolutions, by default True
- use_causal_conv (bool, optional):
Whether to use causal padding in the upsample network and residual blocks, by default False
- upsample_scales (List[int], optional):
Upsample scales of the upsample network, by default [4, 4, 4, 4]
- nonlinear_activation (Optional[str], optional):
Non linear activation in upsample network, by default None
- nonlinear_activation_params (Dict[str, Any], optional):
Parameters passed to the linear activation in the upsample network, by default {}
- interpolate_mode (str, optional):
Interpolation mode of the upsample network, by default "nearest"
- freq_axis_kernel_size (int, optional):
Kernel size along the frequency axis of the upsample network, by default 1
Methods
__call__
(*inputs, **kwargs)Call self as a function.
add_parameter
(name, parameter)Adds a Parameter instance.
add_sublayer
(name, sublayer)Adds a sub Layer instance.
apply
(fn)Applies
fn
recursively to every sublayer (as returned by.sublayers()
) as well as self.Recursively apply weight normalization to all the Convolution layers in the sublayers.
buffers
([include_sublayers])Returns a list of all buffers from current layer and its sub-layers.
children
()Returns an iterator over immediate children layers.
clear_gradients
()Clear the gradients of all parameters for this layer.
create_parameter
(shape[, attr, dtype, ...])Create parameters for this layer.
create_tensor
([name, persistable, dtype])Create Tensor for this layer.
create_variable
([name, persistable, dtype])Create Tensor for this layer.
eval
()Sets this Layer and all its sublayers to evaluation mode.
extra_repr
()Extra representation of this layer, you can have custom implementation of your own layer.
forward
(x, c)Generate waveform.
full_name
()Full name for this layer, composed by name_scope + "/" + MyLayer.__class__.__name__
inference
([c])Waveform generation.
load_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
named_buffers
([prefix, include_sublayers])Returns an iterator over all buffers in the Layer, yielding tuple of name and Tensor.
named_children
()Returns an iterator over immediate children layers, yielding both the name of the layer as well as the layer itself.
named_parameters
([prefix, include_sublayers])Returns an iterator over all parameters in the Layer, yielding tuple of name and parameter.
named_sublayers
([prefix, include_self, ...])Returns an iterator over all sublayers in the Layer, yielding tuple of name and sublayer.
parameters
([include_sublayers])Returns a list of all Parameters from current layer and its sub-layers.
register_buffer
(name, tensor[, persistable])Registers a tensor as buffer into the layer.
register_forward_post_hook
(hook)Register a forward post-hook for Layer.
register_forward_pre_hook
(hook)Register a forward pre-hook for Layer.
Recursively remove weight normalization from all the Convolution layers in the sublayers.
set_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
set_state_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
state_dict
([destination, include_sublayers, ...])Get all parameters and persistable buffers of current layer and its sub-layers.
sublayers
([include_self])Returns a list of sub layers.
to
([device, dtype, blocking])Cast the parameters and buffers of Layer by the give device, dtype and blocking.
to_static_state_dict
([destination, ...])Get all parameters and buffers of current layer and its sub-layers.
train
()Sets this Layer and all its sublayers to training mode.
backward
register_state_dict_hook
- apply_weight_norm()[source]
Recursively apply weight normalization to all the Convolution layers in the sublayers.
- forward(x, c)[source]
Generate waveform.
- Args:
- x(Tensor):
Shape (N, C_in, T), The input waveform.
- c(Tensor):
Shape (N, C_aux, T'). The auxiliary input (e.g. spectrogram). It is upsampled to match the time resolution of the input.
- Returns:
Tensor: Shape (N, C_out, T), the generated waveform.
- inference(c=None)[source]
Waveform generation. This function is used for single instance inference.
- Args:
- c(Tensor, optional, optional):
Shape (T', C_aux), the auxiliary input, by default None
- x(Tensor, optional):
Shape (T, C_in), the noise waveform, by default None
- Returns:
Tensor: Shape (T, C_out), the generated waveform
- class paddlespeech.t2s.models.parallel_wavegan.parallel_wavegan.PWGInference(normalizer, pwg_generator)[source]
Bases:
Layer
Methods
__call__
(*inputs, **kwargs)Call self as a function.
add_parameter
(name, parameter)Adds a Parameter instance.
add_sublayer
(name, sublayer)Adds a sub Layer instance.
apply
(fn)Applies
fn
recursively to every sublayer (as returned by.sublayers()
) as well as self.buffers
([include_sublayers])Returns a list of all buffers from current layer and its sub-layers.
children
()Returns an iterator over immediate children layers.
clear_gradients
()Clear the gradients of all parameters for this layer.
create_parameter
(shape[, attr, dtype, ...])Create parameters for this layer.
create_tensor
([name, persistable, dtype])Create Tensor for this layer.
create_variable
([name, persistable, dtype])Create Tensor for this layer.
eval
()Sets this Layer and all its sublayers to evaluation mode.
extra_repr
()Extra representation of this layer, you can have custom implementation of your own layer.
forward
(logmel)Defines the computation performed at every call.
full_name
()Full name for this layer, composed by name_scope + "/" + MyLayer.__class__.__name__
load_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
named_buffers
([prefix, include_sublayers])Returns an iterator over all buffers in the Layer, yielding tuple of name and Tensor.
named_children
()Returns an iterator over immediate children layers, yielding both the name of the layer as well as the layer itself.
named_parameters
([prefix, include_sublayers])Returns an iterator over all parameters in the Layer, yielding tuple of name and parameter.
named_sublayers
([prefix, include_self, ...])Returns an iterator over all sublayers in the Layer, yielding tuple of name and sublayer.
parameters
([include_sublayers])Returns a list of all Parameters from current layer and its sub-layers.
register_buffer
(name, tensor[, persistable])Registers a tensor as buffer into the layer.
register_forward_post_hook
(hook)Register a forward post-hook for Layer.
register_forward_pre_hook
(hook)Register a forward pre-hook for Layer.
set_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
set_state_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
state_dict
([destination, include_sublayers, ...])Get all parameters and persistable buffers of current layer and its sub-layers.
sublayers
([include_self])Returns a list of sub layers.
to
([device, dtype, blocking])Cast the parameters and buffers of Layer by the give device, dtype and blocking.
to_static_state_dict
([destination, ...])Get all parameters and buffers of current layer and its sub-layers.
train
()Sets this Layer and all its sublayers to training mode.
backward
register_state_dict_hook
- class paddlespeech.t2s.models.parallel_wavegan.parallel_wavegan.ResidualPWGDiscriminator(in_channels: int = 1, out_channels: int = 1, kernel_size: int = 3, layers: int = 30, stacks: int = 3, residual_channels: int = 64, gate_channels: int = 128, skip_channels: int = 64, dropout: float = 0.0, bias: bool = True, use_weight_norm: bool = True, use_causal_conv: bool = False, nonlinear_activation: str = 'leakyrelu', nonlinear_activation_params: Dict[str, Any] = {'negative_slope': 0.2}, init_type: str = 'xavier_uniform')[source]
Bases:
Layer
A wavenet-style discriminator for audio.
- Args:
- in_channels (int, optional):
Number of channels of the input audio, by default 1
- out_channels (int, optional):
Output feature size, by default 1
- kernel_size (int, optional):
Kernel size of residual blocks, by default 3
- layers (int, optional):
Number of residual blocks, by default 30
- stacks (int, optional):
Number of groups of residual blocks, within which the dilation of each residual blocks grows exponentially, by default 3
- residual_channels (int, optional):
Residual channels of residual blocks, by default 64
- gate_channels (int, optional):
Gate channels of residual blocks, by default 128
- skip_channels (int, optional):
Skip channels of residual blocks, by default 64
- dropout (float, optional):
Dropout probability of residual blocks, by default 0.
- bias (bool, optional):
Whether to use bias in residual blocks, by default True
- use_weight_norm (bool, optional):
Whether to use weight normalization in all convolutional layers, by default True
- use_causal_conv (bool, optional):
Whether to use causal convolution in residual blocks, by default False
- nonlinear_activation (str, optional):
Activation after convolutions other than those in residual blocks, by default "leakyrelu"
- nonlinear_activation_params (Dict[str, Any], optional):
Parameters to pass to the activation, by default {"negative_slope": 0.2}
Methods
__call__
(*inputs, **kwargs)Call self as a function.
add_parameter
(name, parameter)Adds a Parameter instance.
add_sublayer
(name, sublayer)Adds a sub Layer instance.
apply
(fn)Applies
fn
recursively to every sublayer (as returned by.sublayers()
) as well as self.buffers
([include_sublayers])Returns a list of all buffers from current layer and its sub-layers.
children
()Returns an iterator over immediate children layers.
clear_gradients
()Clear the gradients of all parameters for this layer.
create_parameter
(shape[, attr, dtype, ...])Create parameters for this layer.
create_tensor
([name, persistable, dtype])Create Tensor for this layer.
create_variable
([name, persistable, dtype])Create Tensor for this layer.
eval
()Sets this Layer and all its sublayers to evaluation mode.
extra_repr
()Extra representation of this layer, you can have custom implementation of your own layer.
forward
(x)Args:
full_name
()Full name for this layer, composed by name_scope + "/" + MyLayer.__class__.__name__
load_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
named_buffers
([prefix, include_sublayers])Returns an iterator over all buffers in the Layer, yielding tuple of name and Tensor.
named_children
()Returns an iterator over immediate children layers, yielding both the name of the layer as well as the layer itself.
named_parameters
([prefix, include_sublayers])Returns an iterator over all parameters in the Layer, yielding tuple of name and parameter.
named_sublayers
([prefix, include_self, ...])Returns an iterator over all sublayers in the Layer, yielding tuple of name and sublayer.
parameters
([include_sublayers])Returns a list of all Parameters from current layer and its sub-layers.
register_buffer
(name, tensor[, persistable])Registers a tensor as buffer into the layer.
register_forward_post_hook
(hook)Register a forward post-hook for Layer.
register_forward_pre_hook
(hook)Register a forward pre-hook for Layer.
set_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
set_state_dict
(state_dict[, use_structured_name])Set parameters and persistable buffers from state_dict.
state_dict
([destination, include_sublayers, ...])Get all parameters and persistable buffers of current layer and its sub-layers.
sublayers
([include_self])Returns a list of sub layers.
to
([device, dtype, blocking])Cast the parameters and buffers of Layer by the give device, dtype and blocking.
to_static_state_dict
([destination, ...])Get all parameters and buffers of current layer and its sub-layers.
train
()Sets this Layer and all its sublayers to training mode.
apply_weight_norm
backward
register_state_dict_hook
remove_weight_norm