Ë
    T^(h¬  ã                   ó0   — d Z ddlmZ  G d„ de«      ZdgZy)z$Speech processor class for SpeechT5.é   )ÚProcessorMixinc                   óB   ‡ — e Zd ZdZdZdZˆ fd„Zd„ Zd„ Zd„ Z	d„ Z
ˆ xZS )	ÚSpeechT5Processora}  
    Constructs a SpeechT5 processor which wraps a feature extractor and a tokenizer into a single processor.

    [`SpeechT5Processor`] offers all the functionalities of [`SpeechT5FeatureExtractor`] and [`SpeechT5Tokenizer`]. See
    the docstring of [`~SpeechT5Processor.__call__`] and [`~SpeechT5Processor.decode`] for more information.

    Args:
        feature_extractor (`SpeechT5FeatureExtractor`):
            An instance of [`SpeechT5FeatureExtractor`]. The feature extractor is a required input.
        tokenizer (`SpeechT5Tokenizer`):
            An instance of [`SpeechT5Tokenizer`]. The tokenizer is a required input.
    ÚSpeechT5FeatureExtractorÚSpeechT5Tokenizerc                 ó&   •— t         ‰| �  ||«       y )N)ÚsuperÚ__init__)ÚselfÚfeature_extractorÚ	tokenizerÚ	__class__s      €ún/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/speecht5/processing_speecht5.pyr
   zSpeechT5Processor.__init__%   s   ø€ Ü‰ÑÐ*¨IÕ6ó    c                 ó<  — |j                  dd«      }|j                  dd«      }|j                  dd«      }|j                  dd«      }|j                  dd«      }|�|�t        d«      ‚|�|�t        d«      ‚|€|€|€|€t        d	«      ‚|� | j                  |g|¢­d|i|¤Ž}n|� | j                  |fi |¤Ž}nd}|� | j                  |||d
œ|¤Ž}	|	d   }
n|� | j                  |fi |¤Ž}	|	d   }
nd}	|€|	S |	�
|d<   |	j	                  d«      }|�||d<   |S )a�  
        Processes audio and text input, as well as audio and text targets.

        You can process audio by using the argument `audio`, or process audio targets by using the argument
        `audio_target`. This forwards the arguments to SpeechT5FeatureExtractor's
        [`~SpeechT5FeatureExtractor.__call__`].

        You can process text by using the argument `text`, or process text labels by using the argument `text_target`.
        This forwards the arguments to SpeechT5Tokenizer's [`~SpeechT5Tokenizer.__call__`].

        Valid input combinations are:

        - `text` only
        - `audio` only
        - `text_target` only
        - `audio_target` only
        - `text` and `audio_target`
        - `audio` and `audio_target`
        - `text` and `text_target`
        - `audio` and `text_target`

        Please refer to the docstring of the above two methods for more information.
        ÚaudioNÚtextÚtext_targetÚaudio_targetÚsampling_ratez\Cannot process both `audio` and `text` inputs. Did you mean `audio_target` or `text_target`?z\Cannot process both `audio_target` and `text_target` inputs. Did you mean `audio` or `text`?zaYou need to specify either an `audio`, `audio_target`, `text`, or `text_target` input to process.)r   r   Úinput_valuesÚ	input_idsÚlabelsÚattention_maskÚdecoder_attention_mask)ÚpopÚ
ValueErrorr   r   Úget)r   ÚargsÚkwargsr   r   r   r   r   ÚinputsÚtargetsr   r   s               r   Ú__call__zSpeechT5Processor.__call__(   s’  € ð0 —
‘
˜7 DÓ)ˆØ�z‰z˜& $Ó'ˆØ—j‘j °Ó5ˆØ—z‘z .°$Ó7ˆØŸ
™
 ?°DÓ9ˆàÐ Ð!1ÜØnóð ð Ð#¨Ð(?ÜØnóð ð ˆ=˜\Ð1°d°lÀ{ÐGZÜØsóð ð ÐØ+�T×+Ñ+¨EÐ`°DÒ`ÈÐ`ÐY_Ñ`‰FØÐØ#�T—^‘^ DÑ3¨FÑ3‰FàˆFàÐ#Ø,�d×,Ñ,È¸,Ð]jÑuÐntÑuˆGØ˜^Ñ,‰FØÐ$Ø$�d—n‘n [Ñ;°FÑ;ˆGØ˜[Ñ)‰FàˆGàˆ>ØˆNàÐØ%ˆF�8Ñà%,§[¡[Ð1AÓ%BÐ"Ø%Ð1Ø3I�Ð/Ñ0àˆr   c                 óê  — |j                  dd«      }|j                  dd«      }|j                  dd«      }|�|�t        d«      ‚|€|€|€t        d«      ‚|�! | j                  j                  |g|¢­i |¤Ž}n"|� | j                  j                  |fi |¤Ž}nd}|�°d|v st        |t        «      r*d|d   v r# | j                  j                  |fi |¤Ž}|d   }nt| j                  j                  }| j                  j                  | j                  _         | j                  j                  |g|¢­i |¤Ž}|| j                  _        |d   }nd}|€|S |�||d<   |j                  d«      }	|	�|	|d	<   |S )
au  
        Collates the audio and text inputs, as well as their targets, into a padded batch.

        Audio inputs are padded by SpeechT5FeatureExtractor's [`~SpeechT5FeatureExtractor.pad`]. Text inputs are padded
        by SpeechT5Tokenizer's [`~SpeechT5Tokenizer.pad`].

        Valid input combinations are:

        - `input_ids` only
        - `input_values` only
        - `labels` only, either log-mel spectrograms or text tokens
        - `input_ids` and log-mel spectrogram `labels`
        - `input_values` and text `labels`

        Please refer to the docstring of the above two methods for more information.
        r   Nr   r   z:Cannot process both `input_values` and `input_ids` inputs.zZYou need to specify either an `input_values`, `input_ids`, or `labels` input to be padded.é    r   r   )
r   r   r   Úpadr   Ú
isinstanceÚlistÚfeature_sizeÚnum_mel_binsr   )
r   r   r    r   r   r   r!   r"   Úfeature_size_hackr   s
             r   r&   zSpeechT5Processor.pado   s¯  € ð" —z‘z .°$Ó7ˆØ—J‘J˜{¨DÓ1ˆ	Ø—‘˜H dÓ+ˆàÐ#¨	Ð(=ÜÐYÓZÐZØÐ IÐ$5¸&¸.ÜØlóð ð Ð#Ø/�T×+Ñ+×/Ñ/°ÐN¸tÒNÀvÑN‰FØÐ"Ø'�T—^‘^×'Ñ'¨	Ñ<°VÑ<‰FàˆFàÐØ˜fÑ$¬°F¼DÔ)AÀkÐU[Ð\]ÑU^ÑF^Ø,˜$Ÿ.™.×,Ñ,¨VÑ>°vÑ>�Ø  Ñ-‘à$(×$:Ñ$:×$GÑ$GÐ!Ø6:×6LÑ6L×6YÑ6Y�×&Ñ&Ô3Ø4˜$×0Ñ0×4Ñ4°VÐM¸dÒMÀfÑM�Ø6G�×&Ñ&Ô3Ø  Ñ0‘àˆGàˆ>ØˆNàÐØ%ˆF�8Ñà%,§[¡[Ð1AÓ%BÐ"Ø%Ð1Ø3I�Ð/Ñ0àˆr   c                 ó:   —  | j                   j                  |i |¤ŽS )z¿
        This method forwards all its arguments to SpeechT5Tokenizer's [`~SpeechT5Tokenizer.batch_decode`]. Please refer
        to the docstring of this method for more information.
        )r   Úbatch_decode©r   r   r    s      r   r-   zSpeechT5Processor.batch_decode«   s    € ð
 +ˆt�~‰~×*Ñ*¨DÐ;°FÑ;Ð;r   c                 ó:   —  | j                   j                  |i |¤ŽS )z¹
        This method forwards all its arguments to SpeechT5Tokenizer's [`~SpeechT5Tokenizer.decode`]. Please refer to
        the docstring of this method for more information.
        )r   Údecoder.   s      r   r0   zSpeechT5Processor.decode²   s    € ð
 %ˆt�~‰~×$Ñ$ dÐ5¨fÑ5Ð5r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úfeature_extractor_classÚtokenizer_classr
   r#   r&   r-   r0   Ú__classcell__)r   s   @r   r   r      s1   ø„ ñð 9ÐØ)€Oô7òEòN:òx<ö6r   r   N)r4   Úprocessing_utilsr   r   Ú__all__© r   r   ú<module>r;      s&   ðñ +å .ôc6˜ô c6ðL Ð
�r   