o
    
j`                     @   s@   d dl mZmZ d dlmZ d dlmZ eG dd deZdS )    )	dataclassfield)Dict)BaseGANVocoderConfigc                       sv  e Zd ZU dZdZeed< dZeed< dZ	eed< dZ
eed	< ed
d dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< edd dZeed< dZeed< dZeed< dZeed< dZeed< dZeed < ed!d dZeed"< d#Zeed$< d#Zeed%< d&Z eed'< d&Z!eed(< ed)d dZ"eed*< d+Z#eed,<  fd-d.Z$  Z%S )/UnivnetConfiga  Defines parameters for UnivNet vocoder.

    Example:

        >>> from TTS.vocoder.configs import UnivNetConfig
        >>> config = UnivNetConfig()

    Args:
        model (str):
            Model name used for selecting the right model at initialization. Defaults to `UnivNet`.
        discriminator_model (str): One of the discriminators from `TTS.vocoder.models.*_discriminator`. Defaults to
            'UnivNet_discriminator`.
        generator_model (str): One of the generators from TTS.vocoder.models.*`. Every other non-GAN vocoder model is
            considered as a generator too. Defaults to `UnivNet_generator`.
        generator_model_params (dict): Parameters of the generator model. Defaults to
            `
            {
                "use_mel": True,
                "sample_rate": 22050,
                "n_fft": 1024,
                "hop_length": 256,
                "win_length": 1024,
                "n_mels": 80,
                "mel_fmin": 0.0,
                "mel_fmax": None,
            }
            `
        batch_size (int):
            Batch size used at training. Larger values use more memory. Defaults to 32.
        seq_len (int):
            Audio segment length used at training. Larger values use more memory. Defaults to 8192.
        pad_short (int):
            Additional padding applied to the audio samples shorter than `seq_len`. Defaults to 0.
        use_noise_augment (bool):
            enable / disable random noise added to the input waveform. The noise is added after computing the
            features. Defaults to True.
        use_cache (bool):
            enable / disable in memory caching of the computed features. It can cause OOM error if the system RAM is
            not large enough. Defaults to True.
        use_stft_loss (bool):
            enable / disable use of STFT loss originally used by ParallelWaveGAN model. Defaults to True.
        use_subband_stft (bool):
            enable / disable use of subband loss computation originally used by MultiBandMelgan model. Defaults to True.
        use_mse_gan_loss (bool):
            enable / disable using Mean Squeare Error GAN loss. Defaults to True.
        use_hinge_gan_loss (bool):
            enable / disable using Hinge GAN loss. You should choose either Hinge or MSE loss for training GAN models.
            Defaults to False.
        use_feat_match_loss (bool):
            enable / disable using Feature Matching loss originally used by MelGAN model. Defaults to True.
        use_l1_spec_loss (bool):
            enable / disable using L1 spectrogram loss originally used by univnet model. Defaults to False.
        stft_loss_params (dict):
            STFT loss parameters. Default to
            `{
                "n_ffts": [1024, 2048, 512],
                "hop_lengths": [120, 240, 50],
                "win_lengths": [600, 1200, 240]
            }`
        l1_spec_loss_params (dict):
            L1 spectrogram loss parameters. Default to
            `{
                "use_mel": True,
                "sample_rate": 22050,
                "n_fft": 1024,
                "hop_length": 256,
                "win_length": 1024,
                "n_mels": 80,
                "mel_fmin": 0.0,
                "mel_fmax": None,
            }`
        stft_loss_weight (float): STFT loss weight that multiplies the computed loss before summing up the total
            model loss. Defaults to 0.5.
        subband_stft_loss_weight (float):
            Subband STFT loss weight that multiplies the computed loss before summing up the total loss. Defaults to 0.
        mse_G_loss_weight (float):
            MSE generator loss weight that multiplies the computed loss before summing up the total loss. faults to 2.5.
        hinge_G_loss_weight (float):
            Hinge generator loss weight that multiplies the computed loss before summing up the total loss. Defaults to 0.
        feat_match_loss_weight (float):
            Feature matching loss weight that multiplies the computed loss before summing up the total loss. faults to 108.
        l1_spec_loss_weight (float):
            L1 spectrogram loss weight that multiplies the computed loss before summing up the total loss. Defaults to 0.
    univnetmodel    
batch_sizeunivnet_discriminatordiscriminator_modelunivnet_generatorgenerator_modelc                   C   s   ddddg ddddddd	
S )
N@      r	   P   )   r      r              )
in_channelsout_channelshidden_channelscond_channelsupsample_factorslvc_layers_each_blocklvc_kernel_sizekpnet_hidden_channelskpnet_conv_sizedropout r    r    r    U/home/kuhnn/.local/lib/python3.10/site-packages/TTS/vocoder/configs/univnet_config.py<lambda>d   s   zUnivnetConfig.<lambda>)default_factorygenerator_model_paramsTuse_stft_lossFuse_subband_stft_lossuse_mse_gan_lossuse_hinge_gan_lossuse_feat_match_lossuse_l1_spec_lossg      @stft_loss_weightc                   C   s   g dg dg ddS )N)   i   i   )x      2   )iX  i  r.   )n_fftshop_lengthswin_lengthsr    r    r    r    r!   r"   }   s   stft_loss_paramsr   subband_stft_loss_weightr   mse_G_loss_weighthinge_G_loss_weightfeat_match_loss_weightl1_spec_loss_weightc                	   C   s   dddddddd dS )NTi"V  r,      r   r   )use_melsample_raten_fft
hop_length
win_lengthn_melsmel_fminmel_fmaxr    r    r    r    r!   r"      s   l1_spec_loss_paramsg-C6?lr_genlr_discNlr_scheduler_genlr_scheduler_discc                   C   s   ddgddS )Ng      ?g?r   )betasweight_decayr    r    r    r    r!   r"      s    optimizer_paramsi@ steps_to_start_discriminatorc                    s   t    | jj| jd< d S )Nr   )super__post_init__audionum_melsr$   )self	__class__r    r!   rL      s   
zUnivnetConfig.__post_init__)&__name__
__module____qualname____doc__r   str__annotations__r
   intr   r   r   r$   r   r%   boolr&   r'   r(   r)   r*   r+   floatr3   r4   r5   r6   r7   r8   rB   rC   rD   rE   rF   rI   rJ   rL   __classcell__r    r    rP   r!   r      sD   
 Ur   N)dataclassesr   r   typingr   "TTS.vocoder.configs.shared_configsr   r   r    r    r    r!   <module>   s
    