o
    
j                     @   sL   d dl mZmZ d dlmZ d dlmZ d dlmZ eG dd deZ	dS )    )	dataclassfield)List)BaseTTSConfigForwardTTSArgsc                   @   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< 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< 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.< d/Z%eed0< d1Z&eed2< dZ'eed3< dZ(eed4< ed5d dZ)e*e ed6< d7d8 Z+dS )9SpeedySpeechConfigu  Configure `ForwardTTS` as SpeedySpeech model.

    Example:

        >>> from TTS.tts.configs.speedy_speech_config import SpeedySpeechConfig
        >>> config = SpeedySpeechConfig()

     Args:
        model (str):
            Model name used for selecting the right model at initialization. Defaults to `speedy_speech`.

        base_model (str):
            Name of the base model being configured as this model so that 🐸 TTS knows it needs to initiate
            the base model rather than searching for the `model` implementation. Defaults to `forward_tts`.

        model_args (Coqpit):
            Model class arguments. Check `FastPitchArgs` for more details. Defaults to `FastPitchArgs()`.

        data_dep_init_steps (int):
            Number of steps used for computing normalization parameters at the beginning of the training. GlowTTS uses
            Activation Normalization that pre-computes normalization stats at the beginning and use the same values
            for the rest. Defaults to 10.

        speakers_file (str):
            Path to the file containing the list of speakers. Needed at inference for loading matching speaker ids to
            speaker names. Defaults to `None`.

        use_speaker_embedding (bool):
            enable / disable using speaker embeddings for multi-speaker models. If set True, the model is
            in the multi-speaker mode. Defaults to False.

        use_d_vector_file (bool):
            enable /disable using external speaker embeddings in place of the learned embeddings. Defaults to False.

        d_vector_file (str):
            Path to the file including pre-computed speaker embeddings. Defaults to None.

        d_vector_dim (int):
            Dimension of the external speaker embeddings. Defaults to 0.

        optimizer (str):
            Name of the model optimizer. Defaults to `RAdam`.

        optimizer_params (dict):
            Arguments of the model optimizer. Defaults to `{"betas": [0.9, 0.998], "weight_decay": 1e-6}`.

        lr_scheduler (str):
            Name of the learning rate scheduler. Defaults to `Noam`.

        lr_scheduler_params (dict):
            Arguments of the learning rate scheduler. Defaults to `{"warmup_steps": 4000}`.

        lr (float):
            Initial learning rate. Defaults to `1e-3`.

        grad_clip (float):
            Gradient norm clipping value. Defaults to `5.0`.

        spec_loss_type (str):
            Type of the spectrogram loss. Check `ForwardTTSLoss` for possible values. Defaults to `l1`.

        duration_loss_type (str):
            Type of the duration loss. Check `ForwardTTSLoss` for possible values. Defaults to `huber`.

        use_ssim_loss (bool):
            Enable/disable the use of SSIM (Structural Similarity) loss. Defaults to True.

        wd (float):
            Weight decay coefficient. Defaults to `1e-7`.

        ssim_loss_alpha (float):
            Weight for the SSIM loss. If set 0, disables the SSIM loss. Defaults to 1.0.

        dur_loss_alpha (float):
            Weight for the duration predictor's loss. If set 0, disables the huber loss. Defaults to 1.0.

        spec_loss_alpha (float):
            Weight for the L1 spectrogram loss. If set 0, disables the L1 loss. Defaults to 1.0.

        binary_loss_alpha (float):
            Weight for the binary loss. If set 0, disables the binary loss. Defaults to 1.0.

        binary_loss_warmup_epochs (float):
            Number of epochs to gradually increase the binary loss impact. Defaults to 150.

        min_seq_len (int):
            Minimum input sequence length to be used at training.

        max_seq_len (int):
            Maximum input sequence length to be used at training. Larger values result in more VRAM usage.
    speedy_speechmodelforward_tts
base_modelc                   C   sJ   t ddddg d dg ddddddg d	 dg dd
dddddd	S )NFresidual_conv_bn   )      r   r   r      )kernel_size	dilationsnum_conv_blocksnum_res_blocks)r   r   r         P      T)		use_pitchencoder_typeencoder_paramsdecoder_typedecoder_paramsout_channelshidden_channelspositional_encodingdetach_duration_predictorr    r#   r#   W/home/kuhnn/.local/lib/python3.10/site-packages/TTS/tts/configs/speedy_speech_config.py<lambda>k   s&    zSpeedySpeechConfig.<lambda>)default_factory
model_argsr   num_speakersNspeakers_fileFuse_speaker_embeddinguse_d_vector_filed_vector_filed_vector_dimAdam	optimizerc                   C   s   ddgddS )Ng?gV-?gư>)betasweight_decayr#   r#   r#   r#   r$   r%      s    optimizer_paramsNoamLRlr_schedulerc                   C   s   ddiS )Nwarmup_stepsi  r#   r#   r#   r#   r$   r%          lr_scheduler_paramsg-C6?lrg      @	grad_clipl1spec_loss_typehuberduration_loss_typeuse_ssim_lossg      ?ssim_loss_alphadur_loss_alphaspec_loss_alphaaligner_loss_alphag333333?binary_align_loss_alpha   binary_loss_warmup_epochsr   min_seq_len   max_seq_lenr   r
compute_f0f0_cache_pathc                   C   s   g dS )N)zcIt took me quite a long time to develop a voice, and now that I have it I'm not going to be silent.zBe a voice, not an echo.z+I'm sorry Dave. I'm afraid I can't do that.z0This cake is great. It's so delicious and moist.zPrior to November 22, 1963.r#   r#   r#   r#   r$   r%      r6   test_sentencesc                 C   sv   | j dkr
| j | j_ | jrd| j_| jr| j| j_| jr d| j_| jd ur/| jdkr/| j| j_| jr9| j| j_d S d S )Nr   T)r(   r'   r*   r)   r+   r-   r,   )selfr#   r#   r$   __post_init__   s   



z SpeedySpeechConfig.__post_init__),__name__
__module____qualname____doc__r
   str__annotations__r   r   r'   r   r(   intr)   r*   boolr+   r,   r-   r/   r2   dictr4   r7   r8   floatr9   r;   r=   r>   r?   r@   rA   rB   rC   rE   rF   rH   rI   rJ   rK   rL   r   rN   r#   r#   r#   r$   r      sJ   
 \
r   N)
dataclassesr   r   typingr   TTS.tts.configs.shared_configsr   TTS.tts.models.forward_ttsr   r   r#   r#   r#   r$   <module>   s    