o
    
j                     @   s4   d dl mZmZ d dlmZ eG dd deZdS )    )	dataclassfield)BaseGANVocoderConfigc                   @   s  e Zd ZU dZdZeed< dZeed< ed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< ed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)< 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d0< d1Z&eed2< d3Z'eed4< d5Z(eed6< d3Z)eed7< d8Z*eed9< d3Z+eed:< d;S )<MultibandMelganConfigaJ  Defines parameters for MultiBandMelGAN vocoder.

    Example:

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

    Args:
        model (str):
            Model name used for selecting the right model at initialization. Defaults to `multiband_melgan`.
        discriminator_model (str): One of the discriminators from `TTS.vocoder.models.*_discriminator`. Defaults to
            'melgan_multiscale_discriminator`.
        discriminator_model_params (dict): The discriminator model parameters. Defaults to
            '{
                "base_channels": 16,
                "max_channels": 512,
                "downsample_factors": [4, 4, 4]
            }`
        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 `melgan_generator`.
        generator_model_param (dict):
            The generator model parameters. Defaults to `{"upsample_factors": [8, 4, 2], "num_res_blocks": 4}`.
        use_pqmf (bool):
            enable / disable PQMF modulation for multi-band training. Defaults to True.
        lr_gen (float):
            Initial learning rate for the generator model. Defaults to 0.0001.
        lr_disc (float):
            Initial learning rate for the discriminator model. Defaults to 0.0001.
        optimizer (torch.optim.Optimizer):
            Optimizer used for the training. Defaults to `AdamW`.
        optimizer_params (dict):
            Optimizer kwargs. Defaults to `{"betas": [0.8, 0.99], "weight_decay": 0.0}`
        lr_scheduler_gen (torch.optim.Scheduler):
            Learning rate scheduler for the generator. Defaults to `MultiStepLR`.
        lr_scheduler_gen_params (dict):
            Parameters for the generator learning rate scheduler. Defaults to
            `{"gamma": 0.5, "milestones": [100000, 200000, 300000, 400000, 500000, 600000]}`.
        lr_scheduler_disc (torch.optim.Scheduler):
            Learning rate scheduler for the discriminator. Defaults to `MultiStepLR`.
        lr_scheduler_dict_params (dict):
            Parameters for the discriminator learning rate scheduler. Defaults to
            `{"gamma": 0.5, "milestones": [100000, 200000, 300000, 400000, 500000, 600000]}`.
        batch_size (int):
            Batch size used at training. Larger values use more memory. Defaults to 16.
        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.
        steps_to_start_discriminator (int):
            Number of steps required to start training the discriminator. Defaults to 0.
        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 HifiGAN 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]}`
        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.
    multiband_melganmodelmelgan_multiscale_discriminatordiscriminator_modelc                   C   s   ddg ddS )N   i   )   r   r   )base_channelsmax_channelsdownsample_factors r   r   r   ^/home/kuhnn/.local/lib/python3.10/site-packages/TTS/vocoder/configs/multiband_melgan_config.py<lambda>b   s    zMultibandMelganConfig.<lambda>)default_factorydiscriminator_model_paramsmultiband_melgan_generatorgenerator_modelc                   C   s   g dddS )N)   r      r   )upsample_factorsnum_res_blocksr   r   r   r   r   r   e       generator_model_paramsTuse_pqmfg-C6?lr_genlr_discAdamW	optimizerc                   C   s   ddgddS )Ng?gGz?g        )betasweight_decayr   r   r   r   r   r   l   r   optimizer_paramsMultiStepLRlr_scheduler_genc                   C      dg ddS N      ?)i @ i i i  i'	 )gamma
milestonesr   r   r   r   r   r   o   r   lr_scheduler_gen_paramslr_scheduler_discc                   C   r&   r'   r   r   r   r   r   r   s   r   lr_scheduler_disc_params@   
batch_sizei @  seq_leni  	pad_shortFuse_noise_augment	use_cacher)   steps_to_start_discriminatoruse_stft_lossuse_subband_stft_lossuse_mse_gan_lossuse_hinge_gan_lossuse_feat_match_lossuse_l1_spec_lossc                   C   s   g dg dg ddS )N)i  i     )   <   
   )   i,  r>   )n_fftshop_lengthswin_lengthsr   r   r   r   r   r      s    subband_stft_loss_paramsr(   stft_loss_weightr   subband_stft_loss_weightg      @mse_G_loss_weighthinge_G_loss_weightl   feat_match_loss_weightl1_spec_loss_weightN),__name__
__module____qualname____doc__r   str__annotations__r	   r   r   dictr   r   r   boolr   floatr   r    r#   r%   r,   r-   r.   r0   intr1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   rD   rE   rF   rG   rH   rJ   rK   r   r   r   r   r      sV   
 Ur   N)dataclassesr   r   "TTS.vocoder.configs.shared_configsr   r   r   r   r   r   <module>   s    