so_vits_svc_fork.modules package

Subpackages

Submodules

so_vits_svc_fork.modules.attentions module

class so_vits_svc_fork.modules.attentions.Decoder(hidden_channels, filter_channels, n_heads, n_layers, kernel_size=1, p_dropout=0.0, proximal_bias=False, proximal_init=True, **kwargs)[source]

Bases: Module

forward(x, x_mask, h, h_mask)[source]

x: decoder input h: encoder output

class so_vits_svc_fork.modules.attentions.Encoder(hidden_channels, filter_channels, n_heads, n_layers, kernel_size=1, p_dropout=0.0, window_size=4, **kwargs)[source]

Bases: Module

forward(x, x_mask)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.attentions.FFN(in_channels, out_channels, filter_channels, kernel_size, p_dropout=0.0, activation=None, causal=False)[source]

Bases: Module

forward(x, x_mask)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.attentions.FFT(hidden_channels, filter_channels, n_heads, n_layers=1, kernel_size=1, p_dropout=0.0, proximal_bias=False, proximal_init=True, **kwargs)[source]

Bases: Module

forward(x, x_mask)[source]

x: decoder input h: encoder output

class so_vits_svc_fork.modules.attentions.MultiHeadAttention(channels, out_channels, n_heads, p_dropout=0.0, window_size=None, heads_share=True, block_length=None, proximal_bias=False, proximal_init=False)[source]

Bases: Module

attention(query, key, value, mask=None)[source]
forward(x, c, attn_mask=None)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

so_vits_svc_fork.modules.commons module

so_vits_svc_fork.modules.commons.clip_grad_value_(parameters, clip_value, norm_type=2)[source]
so_vits_svc_fork.modules.commons.convert_pad_shape(pad_shape)[source]
so_vits_svc_fork.modules.commons.get_padding(kernel_size, dilation=1)[source]
so_vits_svc_fork.modules.commons.init_weights(m, mean=0.0, std=0.01)[source]
so_vits_svc_fork.modules.commons.rand_slice_segments_with_pitch(x: Tensor, f0: Tensor, x_lengths: Tensor | int | None, segment_size: int | None)[source]
so_vits_svc_fork.modules.commons.sequence_mask(length, max_length=None)[source]
so_vits_svc_fork.modules.commons.slice_1d_segments(x: Tensor, starts: Tensor, length: int) Tensor[source]
so_vits_svc_fork.modules.commons.slice_2d_segments(x: Tensor, starts: Tensor, length: int) Tensor[source]
so_vits_svc_fork.modules.commons.slice_segments(x: Tensor, starts: Tensor, length: int) Tensor[source]
so_vits_svc_fork.modules.commons.subsequent_mask(length)[source]

so_vits_svc_fork.modules.descriminators module

class so_vits_svc_fork.modules.descriminators.DiscriminatorP(period, kernel_size=5, stride=3, use_spectral_norm=False)[source]

Bases: Module

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.descriminators.DiscriminatorS(use_spectral_norm=False)[source]

Bases: Module

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.descriminators.MultiPeriodDiscriminator(use_spectral_norm=False)[source]

Bases: Module

forward(y, y_hat)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.descriminators.MultiScaleDiscriminator[source]

Bases: Module

forward(y, y_hat)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

so_vits_svc_fork.modules.encoders module

class so_vits_svc_fork.modules.encoders.Encoder(in_channels, out_channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0)[source]

Bases: Module

forward(x, x_lengths, g=None)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.encoders.SpeakerEncoder(mel_n_channels=80, model_num_layers=3, model_hidden_size=256, model_embedding_size=256)[source]

Bases: Module

compute_partial_slices(total_frames, partial_frames, partial_hop)[source]
embed_utterance(mel, partial_frames=128, partial_hop=64)[source]
forward(mels)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.encoders.TextEncoder(out_channels, hidden_channels, kernel_size, n_layers, gin_channels=0, filter_channels=None, n_heads=None, p_dropout=None)[source]

Bases: Module

forward(x, x_mask, f0=None, noice_scale=1)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

so_vits_svc_fork.modules.flows module

class so_vits_svc_fork.modules.flows.ResidualCouplingBlock(channels, hidden_channels, kernel_size, dilation_rate, n_layers, n_flows=4, gin_channels=0)[source]

Bases: Module

forward(x, x_mask, g=None, reverse=False)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

so_vits_svc_fork.modules.losses module

so_vits_svc_fork.modules.losses.discriminator_loss(disc_real_outputs, disc_generated_outputs)[source]
so_vits_svc_fork.modules.losses.feature_loss(fmap_r, fmap_g)[source]
so_vits_svc_fork.modules.losses.generator_loss(disc_outputs)[source]
so_vits_svc_fork.modules.losses.kl_loss(z_p, logs_q, m_p, logs_p, z_mask)[source]

z_p, logs_q: [b, h, t_t] m_p, logs_p: [b, h, t_t]

so_vits_svc_fork.modules.mel_processing module

from logging import getLogger

import torch import torch.utils.data import torchaudio

LOG = getLogger(__name__)

from ..hparams import HParams

def spectrogram_torch(audio: torch.Tensor, hps: HParams) -> torch.Tensor:
return torchaudio.transforms.Spectrogram(

n_fft=hps.data.filter_length, win_length=hps.data.win_length, hop_length=hps.data.hop_length, power=1.0, window_fn=torch.hann_window, normalized=False,

).to(audio.device)(audio)

def spec_to_mel_torch(spec: torch.Tensor, hps: HParams) -> torch.Tensor:
return torchaudio.transforms.MelScale(

n_mels=hps.data.n_mel_channels, sample_rate=hps.data.sampling_rate, f_min=hps.data.mel_fmin, f_max=hps.data.mel_fmax,

).to(spec.device)(spec)

def mel_spectrogram_torch(audio: torch.Tensor, hps: HParams) -> torch.Tensor:
return torchaudio.transforms.MelSpectrogram(

sample_rate=hps.data.sampling_rate, n_fft=hps.data.filter_length, n_mels=hps.data.n_mel_channels, win_length=hps.data.win_length, hop_length=hps.data.hop_length, f_min=hps.data.mel_fmin, f_max=hps.data.mel_fmax, power=1.0, window_fn=torch.hann_window, normalized=False,

).to(audio.device)(audio)

so_vits_svc_fork.modules.mel_processing.dynamic_range_compression_torch(x, C=1, clip_val=1e-05)[source]

PARAMS

C: compression factor

so_vits_svc_fork.modules.mel_processing.dynamic_range_decompression_torch(x, C=1)[source]

PARAMS

C: compression factor used to compress

so_vits_svc_fork.modules.mel_processing.mel_spectrogram_torch(y, hps, center=False)[source]
so_vits_svc_fork.modules.mel_processing.spec_to_mel_torch(spec, hps)[source]
so_vits_svc_fork.modules.mel_processing.spectral_de_normalize_torch(magnitudes)[source]
so_vits_svc_fork.modules.mel_processing.spectral_normalize_torch(magnitudes)[source]
so_vits_svc_fork.modules.mel_processing.spectrogram_torch(y, hps, center=False)[source]

so_vits_svc_fork.modules.modules module

class so_vits_svc_fork.modules.modules.ConvReluNorm(in_channels, hidden_channels, out_channels, kernel_size, n_layers, p_dropout)[source]

Bases: Module

forward(x, x_mask)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.modules.DDSConv(channels, kernel_size, n_layers, p_dropout=0.0)[source]

Bases: Module

Dialted and Depth-Separable Convolution

forward(x, x_mask, g=None)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.modules.ElementwiseAffine(channels)[source]

Bases: Module

forward(x, x_mask, reverse=False, **kwargs)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.modules.Flip(*args: Any, **kwargs: Any)[source]

Bases: Module

forward(x, *args, reverse=False, **kwargs)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.modules.LayerNorm(channels, eps=1e-05)[source]

Bases: Module

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.modules.Log(*args: Any, **kwargs: Any)[source]

Bases: Module

forward(x, x_mask, reverse=False, **kwargs)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.modules.ResBlock1(channels, kernel_size=3, dilation=(1, 3, 5))[source]

Bases: Module

forward(x, x_mask=None)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

remove_weight_norm()[source]
class so_vits_svc_fork.modules.modules.ResBlock2(channels, kernel_size=3, dilation=(1, 3))[source]

Bases: Module

forward(x, x_mask=None)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

remove_weight_norm()[source]
class so_vits_svc_fork.modules.modules.ResidualCouplingLayer(channels, hidden_channels, kernel_size, dilation_rate, n_layers, p_dropout=0, gin_channels=0, mean_only=False)[source]

Bases: Module

forward(x, x_mask, g=None, reverse=False)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class so_vits_svc_fork.modules.modules.WN(hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0, p_dropout=0)[source]

Bases: Module

forward(x, x_mask, g=None, **kwargs)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

remove_weight_norm()[source]

so_vits_svc_fork.modules.synthesizers module

class so_vits_svc_fork.modules.synthesizers.SynthesizerTrn(spec_channels: int, segment_size: int, inter_channels: int, hidden_channels: int, filter_channels: int, n_heads: int, n_layers: int, kernel_size: int, p_dropout: int, resblock: str, resblock_kernel_sizes: Sequence[int], resblock_dilation_sizes: Sequence[Sequence[int]], upsample_rates: Sequence[int], upsample_initial_channel: int, upsample_kernel_sizes: Sequence[int], gin_channels: int, ssl_dim: int, n_speakers: int, sampling_rate: int = 44100, type_: Literal['hifi-gan', 'istft', 'ms-istft', 'mb-istft'] = 'hifi-gan', gen_istft_n_fft: int = 16, gen_istft_hop_size: int = 4, subbands: int = 4, **kwargs: Any)[source]

Bases: Module

Synthesizer for Training

forward(c, f0, uv, spec, g=None, c_lengths=None, spec_lengths=None)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

infer(c, f0, uv, g=None, noice_scale=0.35, predict_f0=False)[source]