Ë
    S^(hL  ã                   ó<   — d Z ddlmZ ddlmZ  G d„ de«      ZdgZy)z%
Audio/Text processor class for CLAP
é   )ÚProcessorMixin)ÚBatchEncodingc                   óN   ‡ — e Zd ZdZdZdZˆ fd„Zd	d„Zd„ Zd„ Z	e
d„ «       Zˆ xZS )
ÚClapProcessora  
    Constructs a CLAP processor which wraps a CLAP feature extractor and a RoBerta tokenizer into a single processor.

    [`ClapProcessor`] offers all the functionalities of [`ClapFeatureExtractor`] and [`RobertaTokenizerFast`]. See the
    [`~ClapProcessor.__call__`] and [`~ClapProcessor.decode`] for more information.

    Args:
        feature_extractor ([`ClapFeatureExtractor`]):
            The audio processor is a required input.
        tokenizer ([`RobertaTokenizerFast`]):
            The tokenizer is a required input.
    ÚClapFeatureExtractor)ÚRobertaTokenizerÚRobertaTokenizerFastc                 ó&   •— t         ‰| �  ||«       y ©N)ÚsuperÚ__init__)ÚselfÚfeature_extractorÚ	tokenizerÚ	__class__s      €úf/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/clap/processing_clap.pyr   zClapProcessor.__init__(   s   ø€ Ü‰ÑÐ*¨IÕ6ó    c                 ó  — |j                  dd«      }|€|€t        d«      ‚|� | j                  |fd|i|¤Ž}|� | j                  |f||dœ|¤Ž}|�|�j	                  «       |S |�S t        t        di ¤Ž|¬«      S )a	  
        Main method to prepare for the model one or several sequences(s) and audio(s). This method forwards the `text`
        and `kwargs` arguments to RobertaTokenizerFast's [`~RobertaTokenizerFast.__call__`] if `text` is not `None` to
        encode the text. To prepare the audio(s), this method forwards the `audios` and `kwrags` arguments to
        ClapFeatureExtractor's [`~ClapFeatureExtractor.__call__`] if `audios` is not `None`. Please refer to the
        docstring of the above two methods for more information.

        Args:
            text (`str`, `List[str]`, `List[List[str]]`):
                The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
                (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
                `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
            audios (`np.ndarray`, `torch.Tensor`, `List[np.ndarray]`, `List[torch.Tensor]`):
                The audio or batch of audios to be prepared. Each audio can be NumPy array or PyTorch tensor. In case
                of a NumPy array/PyTorch tensor, each audio should be of shape (C, T), where C is a number of channels,
                and T the sample length of the audio.

            return_tensors (`str` or [`~utils.TensorType`], *optional*):
                If set, will return tensors of a particular framework. Acceptable values are:

                - `'tf'`: Return TensorFlow `tf.constant` objects.
                - `'pt'`: Return PyTorch `torch.Tensor` objects.
                - `'np'`: Return NumPy `np.ndarray` objects.
                - `'jax'`: Return JAX `jnp.ndarray` objects.

        Returns:
            [`BatchEncoding`]: A [`BatchEncoding`] with the following fields:

            - **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`.
            - **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
              `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
              `None`).
            - **audio_features** -- Audio features to be fed to a model. Returned when `audios` is not `None`.
        Úsampling_rateNz?You have to specify either text or audios. Both cannot be none.Úreturn_tensors)r   r   )ÚdataÚtensor_type© )ÚpopÚ
ValueErrorr   r   Úupdater   Údict)r   ÚtextÚaudiosr   Úkwargsr   ÚencodingÚaudio_featuress           r   Ú__call__zClapProcessor.__call__+   sµ   € ðF Ÿ
™
 ?°DÓ9ˆàˆ<˜F˜NÜÐ^Ó_Ð_àÐØ%�t—~‘~ dÑT¸>ÐTÈVÑTˆHàÐØ3˜T×3Ñ3ØðØ&3ÀNñØV\ñˆNð Ð Ð 2Ø�O‰O˜NÔ+ØˆOØÐØˆOä ¤dÑ&<¨^Ñ&<È.ÔYÐYr   c                 ó:   —  | j                   j                  |i |¤ŽS )zÄ
        This method forwards all its arguments to RobertaTokenizerFast's [`~PreTrainedTokenizer.batch_decode`]. Please
        refer to the docstring of this method for more information.
        )r   Úbatch_decode©r   Úargsr    s      r   r%   zClapProcessor.batch_decodec   s    € ð
 +ˆt�~‰~×*Ñ*¨DÐ;°FÑ;Ð;r   c                 ó:   —  | j                   j                  |i |¤ŽS )z¾
        This method forwards all its arguments to RobertaTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer
        to the docstring of this method for more information.
        )r   Údecoder&   s      r   r)   zClapProcessor.decodej   s    € ð
 %ˆt�~‰~×$Ñ$ dÐ5¨fÑ5Ð5r   c                 óœ   — | j                   j                  }| j                  j                  }t        t        j                  ||z   «      «      S r   )r   Úmodel_input_namesr   Úlistr   Úfromkeys)r   Útokenizer_input_namesÚfeature_extractor_input_namess      r   r+   zClapProcessor.model_input_namesq   s?   € à $§¡× @Ñ @ÐØ(,×(>Ñ(>×(PÑ(PÐ%Ü”D—M‘MÐ"7Ð:WÑ"WÓXÓYÐYr   )NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úfeature_extractor_classÚtokenizer_classr   r#   r%   r)   Úpropertyr+   Ú__classcell__)r   s   @r   r   r      sA   ø„ ñð 5ÐØB€Oô7ó6Zòp<ò6ð ñZó ôZr   r   N)r3   Úprocessing_utilsr   Útokenization_utils_baser   r   Ú__all__r   r   r   ú<module>r;      s-   ðñõ /Ý 4ô^Z�Nô ^ZðB Ð
�r   