
    i                         d Z ddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZmZ  e	d	
      e G d de                    ZdgZy)zXcodec model configuration    N)strict   )PreTrainedConfig)auto_docstring   )CONFIG_MAPPING
AutoConfigzManel/X-Codec)
checkpointc                       e Zd ZU dZdZeedZdg ddg dddZi Zd	Z	e
eez     eeez  d
f   z  ed<   dZeed<   dZeed<   dZe
e   eed
f   z  ed<   dZe
e   eed
f   z  ed<   dZe
e   eed
f   z  ed<   dZeed<   dZeed<   dZedz  ed<   dZeed<   dZeez  dz  ed<   dZeez  dz  ed<    fdZedefd       Zedefd       Zedefd        Z edefd!       Z!edefd"       Z"edefd#       Z# xZ$S )$XcodecConfigaY  
    target_bandwidths (`List[float]`, *optional*, defaults to `[0.5, 1, 1.5, 2, 4]`):
        The range of different bandwidths (in kbps) the model can encode audio with.
    channel_ratios (`List[float]`, *optional*, defaults to `[1, 1]`):
        Expansion factors for the number of output channels in each semantic block.
    strides (`List[int]`, *optional*, defaults to `[1, 1]`):
        Strides for each semantic encoder block.
    block_dilations (`List[int]`, *optional*, defaults to `[1, 1]`):
        Dilation factors for the residual units in semantic blocks.
    unit_kernel_size (`int`, *optional*, defaults to 3):
        Kernel size inside each ResidualUnit in semantic blocks.
    acoustic_model_config (`Union[Dict, DacConfig]`, *optional*):
        An instance of the configuration for the acoustic (DAC) model.
    semantic_model_config (`Union[Dict, HubertConfig, WavLMConfig]`, *optional*):
        An instance of the configuration object for the semantic (HuBERT) model.

    Example:

    ```python
    >>> from transformers import XcodecModel, XcodecConfig

    >>> # Initializing configuration
    >>> configuration = XcodecConfig()

    >>> # Initializing a model (with random weights) from the configuration
    >>> model = XcodecModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```xcodec)acoustic_model_configsemantic_model_config@            r         encoder_hidden_sizedownsampling_ratiosdecoder_hidden_sizeupsampling_ratioshidden_size)g      ?   g      ?r   r   .target_bandwidthsi>  sample_rater   kernel_size)r   r   channel_ratiosstridesblock_dilationsunit_kernel_sizecodebook_sizeNcodebook_dimg{Gz?initializer_ranger   r   c                    | j                   t        d   dg ddg dd      | _         n{t        | j                   t              ra| j                   j	                  dd      | j                   d<   t        | j                   d      d	i i | j
                  | j                   | _         | j                  t        d          | _        n{t        | j                  t              ra| j                  j	                  dd      | j                  d<   t        | j                  d      d	i i | j                  | j                  | _        | j                  2| j                   j                  | j                  j                  z   | _        t        | ,  d	i | y )
Ndacr   r   r   r   r   
model_typehubert )r   r   
isinstancedictget%_default_acoustic_model_config_kwargsr   %_default_semantic_model_config_kwargsr&   r   super__post_init__)selfkwargs	__class__s     /var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/transformers/models/xcodec/configuration_xcodec.pyr3   zXcodecConfig.__post_init__\   sw   %%-)7)>$& %1$(".*D& 22D97;7Q7Q7U7UVbdi7jD&&|4)78R8RS_8`)a *^T??^4C]C]^*D& %%-)7)A)CD&22D97;7Q7Q7U7UVbdl7mD&&|4)78R8RS_8`)a *^T??^4C]C]^*D& $ $ : : F FIcIcIoIo oD''    returnc                 Z    t        j                  | j                  | j                  z        S N)mathceilr   
hop_lengthr4   s    r7   
frame_ratezXcodecConfig.frame_ratez   s     yy))DOO;<<r8   c                 .    | j                   j                  S r;   )r   r   r?   s    r7   semantic_hidden_sizez!XcodecConfig.semantic_hidden_size~   s    ))555r8   c                 f    t        t        j                  | j                  j                              S r;   )intnpprodr   r   r?   s    r7   r>   zXcodecConfig.hop_length   s"    277455IIJKKr8   c                 f    t        j                  t        j                  | j                              S r;   )r<   r=   log2r%   r?   s    r7   codebook_nbitszXcodecConfig.codebook_nbits   s     yy4#5#5677r8   c                 \    | j                   j                  | j                  j                  z   S r;   )r   r   r   r?   s    r7   r   zXcodecConfig.hidden_size   s%    ))558R8R8^8^^^r8   c                 l    t        d| j                  d   z  | j                  | j                  z  z        S )Ni  )rD   r   r@   rI   r?   s    r7   num_quantizerszXcodecConfig.num_quantizers   s1    4$00444K^K^9^_``r8   )%__name__
__module____qualname____doc__r*   r	   sub_configsr0   r1   r   listrD   floattuple__annotations__r   r    r!   r"   r#   r$   r%   r&   r'   r   r.   r   r   r3   propertyr@   rB   r>   rI   r   rM   __classcell__)r6   s   @r7   r   r      s   > J ",!+K  "  ,#)-) -/)EXtC%K(5uc1A+BBXKK28NDIc3h/8+1GT#YsCx(139OT#YsCx09cM3#L#*##u#<@4"22T9@<@4"22T9@(< =C = = 6c 6 6 LC L L 8 8 8 _S _ _ a a ar8   r   )rQ   r<   numpyrE   huggingface_hub.dataclassesr   configuration_utilsr   utilsr   autor   r	   r   __all__r,   r8   r7   <module>r_      sV    !   . 3 # - ?+ta# ta  ,tan 
r8   