U
    ,È-e[]  ã                   @   sn   d Z ddlZddlZddlmZ ddlmZ e e¡Z	dddd	œZ
d
diZG dd„ deƒZG dd„ deƒZdS )z SpeechT5 model configurationé    Né   )ÚPretrainedConfig)ÚloggingzFhttps://huggingface.co/microsoft/speecht5_asr/resolve/main/config.jsonzFhttps://huggingface.co/microsoft/speecht5_tts/resolve/main/config.jsonzEhttps://huggingface.co/microsoft/speecht5_vc/resolve/main/config.json)zmicrosoft/speecht5_asrzmicrosoft/speecht5_ttszmicrosoft/speecht5_vczmicrosoft/speecht5_hifiganzJhttps://huggingface.co/microsoft/speecht5_hifigan/resolve/main/config.jsonc                9       s8   e Zd ZdZdZdddœZd+‡ fd'd(„	Zd)d*„ Z‡  ZS ),ÚSpeechT5Configa.  
    This is the configuration class to store the configuration of a [`SpeechT5Model`]. It is used to instantiate a
    SpeechT5 model according to the specified arguments, defining the model architecture. Instantiating a configuration
    with the defaults will yield a similar configuration to that of the SpeechT5
    [microsoft/speecht5_asr](https://huggingface.co/microsoft/speecht5_asr) architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        vocab_size (`int`, *optional*, defaults to 81):
            Vocabulary size of the SpeechT5 model. Defines the number of different tokens that can be represented by
            the `inputs_ids` passed to the forward method of [`SpeechT5Model`].
        hidden_size (`int`, *optional*, defaults to 768):
            Dimensionality of the encoder layers and the pooler layer.
        encoder_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the Transformer encoder.
        encoder_attention_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer encoder.
        encoder_ffn_dim (`int`, *optional*, defaults to 3072):
            Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
        encoder_layerdrop (`float`, *optional*, defaults to 0.1):
            The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
            for more details.
        decoder_layers (`int`, *optional*, defaults to 6):
            Number of hidden layers in the Transformer decoder.
        decoder_attention_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer decoder.
        decoder_ffn_dim (`int`, *optional*, defaults to 3072):
            Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer decoder.
        decoder_layerdrop (`float`, *optional*, defaults to 0.1):
            The LayerDrop probability for the decoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
            for more details.
        hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"selu"` and `"gelu_new"` are supported.
        positional_dropout (`float`, *optional*, defaults to 0.1):
            The dropout probability for the text position encoding layers.
        hidden_dropout (`float`, *optional*, defaults to 0.1):
            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
        attention_dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the attention probabilities.
        activation_dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for activations inside the fully connected layer.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        layer_norm_eps (`float`, *optional*, defaults to 1e-5):
            The epsilon used by the layer normalization layers.
        scale_embedding (`bool`, *optional*, defaults to `False`):
            Scale embeddings by diving by sqrt(d_model).
        feat_extract_norm (`str`, *optional*, defaults to `"group"`):
            The norm to be applied to 1D convolutional layers in the speech encoder pre-net. One of `"group"` for group
            normalization of only the first 1D convolutional layer or `"layer"` for layer normalization of all 1D
            convolutional layers.
        feat_proj_dropout (`float`, *optional*, defaults to 0.0):
            The dropout probability for output of the speech encoder pre-net.
        feat_extract_activation (`str, `optional`, defaults to `"gelu"`):
            The non-linear activation function (function or string) in the 1D convolutional layers of the feature
            extractor. If string, `"gelu"`, `"relu"`, `"selu"` and `"gelu_new"` are supported.
        conv_dim (`Tuple[int]` or `List[int]`, *optional*, defaults to `(512, 512, 512, 512, 512, 512, 512)`):
            A tuple of integers defining the number of input and output channels of each 1D convolutional layer in the
            speech encoder pre-net. The length of *conv_dim* defines the number of 1D convolutional layers.
        conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 2, 2, 2, 2, 2)`):
            A tuple of integers defining the stride of each 1D convolutional layer in the speech encoder pre-net. The
            length of *conv_stride* defines the number of convolutional layers and has to match the length of
            *conv_dim*.
        conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 3, 3, 3, 3, 3)`):
            A tuple of integers defining the kernel size of each 1D convolutional layer in the speech encoder pre-net.
            The length of *conv_kernel* defines the number of convolutional layers and has to match the length of
            *conv_dim*.
        conv_bias (`bool`, *optional*, defaults to `False`):
            Whether the 1D convolutional layers have a bias.
        num_conv_pos_embeddings (`int`, *optional*, defaults to 128):
            Number of convolutional positional embeddings. Defines the kernel size of 1D convolutional positional
            embeddings layer.
        num_conv_pos_embedding_groups (`int`, *optional*, defaults to 16):
            Number of groups of 1D convolutional positional embeddings layer.
        apply_spec_augment (`bool`, *optional*, defaults to `True`):
            Whether to apply *SpecAugment* data augmentation to the outputs of the speech encoder pre-net. For
            reference see [SpecAugment: A Simple Data Augmentation Method for Automatic Speech
            Recognition](https://arxiv.org/abs/1904.08779).
        mask_time_prob (`float`, *optional*, defaults to 0.05):
            Percentage (between 0 and 1) of all feature vectors along the time axis which will be masked. The masking
            procecure generates ''mask_time_prob*len(time_axis)/mask_time_length'' independent masks over the axis. If
            reasoning from the propability of each feature vector to be chosen as the start of the vector span to be
            masked, *mask_time_prob* should be `prob_vector_start*mask_time_length`. Note that overlap may decrease the
            actual percentage of masked vectors. This is only relevant if `apply_spec_augment is True`.
        mask_time_length (`int`, *optional*, defaults to 10):
            Length of vector span along the time axis.
        mask_time_min_masks (`int`, *optional*, defaults to 2),:
            The minimum number of masks of length `mask_feature_length` generated along the time axis, each time step,
            irrespectively of `mask_feature_prob`. Only relevant if ''mask_time_prob*len(time_axis)/mask_time_length <
            mask_time_min_masks''
        mask_feature_prob (`float`, *optional*, defaults to 0.0):
            Percentage (between 0 and 1) of all feature vectors along the feature axis which will be masked. The
            masking procecure generates ''mask_feature_prob*len(feature_axis)/mask_time_length'' independent masks over
            the axis. If reasoning from the propability of each feature vector to be chosen as the start of the vector
            span to be masked, *mask_feature_prob* should be `prob_vector_start*mask_feature_length`. Note that overlap
            may decrease the actual percentage of masked vectors. This is only relevant if `apply_spec_augment is
            True`.
        mask_feature_length (`int`, *optional*, defaults to 10):
            Length of vector span along the feature axis.
        mask_feature_min_masks (`int`, *optional*, defaults to 0),:
            The minimum number of masks of length `mask_feature_length` generated along the feature axis, each time
            step, irrespectively of `mask_feature_prob`. Only relevant if
            ''mask_feature_prob*len(feature_axis)/mask_feature_length < mask_feature_min_masks''
        num_mel_bins (`int`, *optional*, defaults to 80):
            Number of mel features used per input features. Used by the speech decoder pre-net. Should correspond to
            the value used in the [`SpeechT5Processor`] class.
        speech_decoder_prenet_layers (`int`, *optional*, defaults to 2):
            Number of layers in the speech decoder pre-net.
        speech_decoder_prenet_units (`int`, *optional*, defaults to 256):
            Dimensionality of the layers in the speech decoder pre-net.
        speech_decoder_prenet_dropout (`float`, *optional*, defaults to 0.5):
            The dropout probability for the speech decoder pre-net layers.
        speaker_embedding_dim (`int`, *optional*, defaults to 512):
            Dimensionality of the *XVector* embedding vectors.
        speech_decoder_postnet_layers (`int`, *optional*, defaults to 5):
            Number of layers in the speech decoder post-net.
        speech_decoder_postnet_units (`int`, *optional*, defaults to 256):
            Dimensionality of the layers in the speech decoder post-net.
        speech_decoder_postnet_kernel (`int`, *optional*, defaults to 5):
            Number of convolutional filter channels in the speech decoder post-net.
        speech_decoder_postnet_dropout (`float`, *optional*, defaults to 0.5):
            The dropout probability for the speech decoder post-net layers.
        reduction_factor (`int`, *optional*, defaults to 2):
            Spectrogram length reduction factor for the speech decoder inputs.
        max_speech_positions (`int`, *optional*, defaults to 4000):
            The maximum sequence length of speech features that this model might ever be used with.
        max_text_positions (`int`, *optional*, defaults to 450):
            The maximum sequence length of text features that this model might ever be used with.
        encoder_max_relative_position (`int`, *optional*, defaults to 160):
            Maximum distance for relative position embedding in the encoder.
        use_guided_attention_loss (`bool`, *optional*, defaults to `True`):
            Whether to apply guided attention loss while training the TTS model.
        guided_attention_loss_num_heads (`int`, *optional*, defaults to 2):
            Number of attention heads the guided attention loss will be applied to. Use -1 to apply this loss to all
            attention heads.
        guided_attention_loss_sigma (`float`, *optional*, defaults to 0.4):
            Standard deviation for guided attention loss.
        guided_attention_loss_scale (`float`, *optional*, defaults to 10.0):
            Scaling coefficient for guided attention loss (also known as lambda).
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models).

    Example:

    ```python
    >>> from transformers import SpeechT5Model, SpeechT5Config

    >>> # Initializing a "microsoft/speecht5_asr" style configuration
    >>> configuration = SpeechT5Config()

    >>> # Initializing a model (with random weights) from the "microsoft/speecht5_asr" style configuration
    >>> model = SpeechT5Model(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Zspeecht5Úencoder_attention_headsÚencoder_layers)Znum_attention_headsZnum_hidden_layerséQ   é   é   é   çš™™™™™¹?é   Úgeluç{®Gáz”?çñhãˆµøä>FÚgroupç        ©é   r   r   r   r   r   r   ©é   é   r   r   r   r   r   ©é
   r   r   r   r   r   r   é€   é   Tçš™™™™™©?r   r   r   é   éP   é   ç      à?r   r   é   éÂ  é    çš™™™™™Ù?ç      $@c:           ;         sØ  || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _t|ƒ| _t|ƒ| _t|ƒ| _|| _|| _|| _t| jƒ| _t| jƒ| jksìt| jƒ| jksìt| jƒ| jkrtdt| jƒ› dt| jƒ› dt| jƒ› dƒ‚|| _|| _ || _!|| _"| | _#|!| _$|"| _%|'| _&|(| _'|)| _(|*| _)|+| _*|,| _+|-| _,|.| _-|/| _.|0| _/|1| _0|2| _1|3| _2|4| _3|5| _4|6| _5|7| _6|8| _7|9| _8t9ƒ j:f |#|$|%|9|&dœ|:—Ž d S )NzºConfiguration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` == `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) = z`, `len(config.conv_stride) = z`, `len(config.conv_kernel) = z`.)Úpad_token_idÚbos_token_idÚeos_token_idÚis_encoder_decoderÚdecoder_start_token_id);Ú
vocab_sizeÚhidden_sizer   Úencoder_ffn_dimr   Úencoder_layerdropÚdecoder_layersÚdecoder_ffn_dimÚdecoder_attention_headsÚdecoder_layerdropÚ
hidden_actÚpositional_dropoutÚhidden_dropoutÚattention_dropoutÚactivation_dropoutÚinitializer_rangeÚlayer_norm_epsÚscale_embeddingÚfeat_extract_normÚfeat_proj_dropoutÚfeat_extract_activationÚlistÚconv_dimÚconv_strideÚconv_kernelÚ	conv_biasÚnum_conv_pos_embeddingsÚnum_conv_pos_embedding_groupsÚlenZnum_feat_extract_layersÚ
ValueErrorÚapply_spec_augmentÚmask_time_probÚmask_time_lengthÚmask_time_min_masksÚmask_feature_probÚmask_feature_lengthÚmask_feature_min_masksÚnum_mel_binsÚspeech_decoder_prenet_layersÚspeech_decoder_prenet_unitsÚspeech_decoder_prenet_dropoutÚspeaker_embedding_dimÚspeech_decoder_postnet_layersÚspeech_decoder_postnet_unitsÚspeech_decoder_postnet_kernelÚspeech_decoder_postnet_dropoutÚreduction_factorÚmax_speech_positionsÚmax_text_positionsÚencoder_max_relative_positionÚuse_guided_attention_lossÚguided_attention_loss_num_headsÚguided_attention_loss_sigmaÚguided_attention_loss_scaleÚ	use_cacher)   ÚsuperÚ__init__);Úselfr+   r,   r   r   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r?   r@   rA   rB   rC   rD   rG   rH   rI   rJ   rK   rL   rM   r&   r'   r(   r*   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r)   Úkwargs©Ú	__class__© út/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/transformers/models/speecht5/configuration_speecht5.pyra   È   s    =


ÿþý(ÿûúzSpeechT5Config.__init__c                 C   s   t  tj| jd¡S )Nr   )Ú	functoolsÚreduceÚoperatorÚmulr@   )rb   rf   rf   rg   Úinputs_to_logits_ratioY  s    z%SpeechT5Config.inputs_to_logits_ratio)9r   r	   r
   r
   r   r   r   r   r
   r   r   r   r   r   r   r   r   Fr   r   r   r   r   r   Fr   r   Tr   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r   r   r    r   r!   r"   r#   Tr   r$   r%   TT)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeZattribute_mapra   rl   Ú__classcell__rf   rf   rd   rg   r   %   s€     
                                                         Æ r   c                       sh   e Zd ZdZdZdddddddgddddgdd	d
gdddgdddgdddggdddf
‡ fdd„	Z‡  ZS )ÚSpeechT5HifiGanConfiga  
    This is the configuration class to store the configuration of a [`SpeechT5HifiGanModel`]. It is used to instantiate
    a SpeechT5 HiFi-GAN vocoder model according to the specified arguments, defining the model architecture.
    Instantiating a configuration with the defaults will yield a similar configuration to that of the SpeechT5
    [microsoft/speecht5_hifigan](https://huggingface.co/microsoft/speecht5_hifigan) architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        model_in_dim (`int`, *optional*, defaults to 80):
            The number of frequency bins in the input log-mel spectrogram.
        sampling_rate (`int`, *optional*, defaults to 16000):
            The sampling rate at which the output audio will be generated, expressed in hertz (Hz).
        upsample_initial_channel (`int`, *optional*, defaults to 512):
            The number of input channels into the upsampling network.
        upsample_rates (`Tuple[int]` or `List[int]`, *optional*, defaults to `[4, 4, 4, 4]`):
            A tuple of integers defining the stride of each 1D convolutional layer in the upsampling network. The
            length of *upsample_rates* defines the number of convolutional layers and has to match the length of
            *upsample_kernel_sizes*.
        upsample_kernel_sizes (`Tuple[int]` or `List[int]`, *optional*, defaults to `[8, 8, 8, 8]`):
            A tuple of integers defining the kernel size of each 1D convolutional layer in the upsampling network. The
            length of *upsample_kernel_sizes* defines the number of convolutional layers and has to match the length of
            *upsample_rates*.
        resblock_kernel_sizes (`Tuple[int]` or `List[int]`, *optional*, defaults to `[3, 7, 11]`):
            A tuple of integers defining the kernel sizes of the 1D convolutional layers in the multi-receptive field
            fusion (MRF) module.
        resblock_dilation_sizes (`Tuple[Tuple[int]]` or `List[List[int]]`, *optional*, defaults to `[[1, 3, 5], [1, 3, 5], [1, 3, 5]]`):
            A nested tuple of integers defining the dilation rates of the dilated 1D convolutional layers in the
            multi-receptive field fusion (MRF) module.
        initializer_range (`float`, *optional*, defaults to 0.01):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        leaky_relu_slope (`float`, *optional*, defaults to 0.1):
            The angle of the negative slope used by the leaky ReLU activation.
        normalize_before (`bool`, *optional*, defaults to `True`):
            Whether or not to normalize the spectrogram before vocoding using the vocoder's learned mean and variance.

    Example:

    ```python
    >>> from transformers import SpeechT5HifiGan, SpeechT5HifiGanConfig

    >>> # Initializing a "microsoft/speecht5_hifigan" style configuration
    >>> configuration = SpeechT5HifiGanConfig()

    >>> # Initializing a model (with random weights) from the "microsoft/speecht5_hifigan" style configuration
    >>> model = SpeechT5HifiGan(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Zhifiganr   i€>  r   é   é   r   é   é   r   r   g{®Gáz„?r   Tc                    sN   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	t
ƒ jf |Ž d S )N)Úmodel_in_dimÚsampling_rateÚupsample_initial_channelÚupsample_ratesÚupsample_kernel_sizesÚresblock_kernel_sizesÚresblock_dilation_sizesr8   Úleaky_relu_slopeÚnormalize_beforer`   ra   )rb   rx   ry   rz   r{   r|   r}   r~   r8   r   r€   rc   rd   rf   rg   ra   “  s    zSpeechT5HifiGanConfig.__init__)rm   rn   ro   rp   rq   ra   rr   rf   rf   rd   rg   rs   ]  s   3

õrs   )rp   rh   rj   Zconfiguration_utilsr   Úutilsr   Z
get_loggerrm   ÚloggerZ&SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAPZ.SPEECHT5_PRETRAINED_HIFIGAN_CONFIG_ARCHIVE_MAPr   rs   rf   rf   rf   rg   Ú<module>   s    
ý ÿ  :