Ë
    T^(h:  ã                   ó¦   — d Z ddlZddlmZ ddlmZmZmZ ddlm	Z	m
Z
mZ ddlmZmZmZ dd	lmZ dd
lmZ  G d„ de	d¬«      Z G d„ de
«      ZdgZy)z%
Speech processor class for Wav2Vec2
é    N)Úcontextmanager)ÚListÚOptionalÚUnioné   )ÚProcessingKwargsÚProcessorMixinÚUnpack)Ú
AudioInputÚPreTokenizedInputÚ	TextInputé   )ÚWav2Vec2FeatureExtractor)ÚWav2Vec2CTCTokenizerc                   ó   — e Zd Zi Zy)ÚWav2Vec2ProcessorKwargsN)Ú__name__Ú
__module__Ú__qualname__Ú	_defaults© ó    ún/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/wav2vec2/processing_wav2vec2.pyr   r      s   „ Ø�Ir   r   F)Útotalc            
       óž   ‡ — e Zd ZdZdZdZˆ fd„Zeˆ fd„«       Z	 	 	 	 dde	de
eeee   eef      dee   fd	„Zd
„ Zd„ Zd„ Zed„ «       Zˆ xZS )ÚWav2Vec2ProcessoraŸ  
    Constructs a Wav2Vec2 processor which wraps a Wav2Vec2 feature extractor and a Wav2Vec2 CTC tokenizer into a single
    processor.

    [`Wav2Vec2Processor`] offers all the functionalities of [`Wav2Vec2FeatureExtractor`] and [`PreTrainedTokenizer`].
    See the docstring of [`~Wav2Vec2Processor.__call__`] and [`~Wav2Vec2Processor.decode`] for more information.

    Args:
        feature_extractor (`Wav2Vec2FeatureExtractor`):
            An instance of [`Wav2Vec2FeatureExtractor`]. The feature extractor is a required input.
        tokenizer ([`PreTrainedTokenizer`]):
            An instance of [`PreTrainedTokenizer`]. The tokenizer is a required input.
    r   ÚAutoTokenizerc                 óV   •— t         ‰| �  ||«       | j                  | _        d| _        y )NF)ÚsuperÚ__init__Úfeature_extractorÚcurrent_processorÚ_in_target_context_manager)Úselfr!   Ú	tokenizerÚ	__class__s      €r   r    zWav2Vec2Processor.__init__3   s)   ø€ Ü‰ÑÐ*¨IÔ6Ø!%×!7Ñ!7ˆÔØ*/ˆÕ'r   c                 ó  •— 	 t        ‰| �  |fi |¤ŽS # t        t        f$ ra t	        j
                  d| j                  › d�t        «       t        j                  |fi |¤Ž}t        j                  |fi |¤Ž} | ||¬«      cY S w xY w)NzLoading a tokenizer inside a   from a config that does not include a `tokenizer_class` attribute is deprecated and will be removed in v5. Please add `'tokenizer_class': 'Wav2Vec2CTCTokenizer'` attribute to either your `config.json` or `tokenizer_config.json` file to suppress this warning: )r!   r%   )
r   Úfrom_pretrainedÚOSErrorÚ
ValueErrorÚwarningsÚwarnr   ÚFutureWarningr   r   )ÚclsÚpretrained_model_name_or_pathÚkwargsr!   r%   r&   s        €r   r(   z!Wav2Vec2Processor.from_pretrained8   sš   ø€ ð	QÜ‘7Ñ*Ð+HÑSÈFÑSÐSøÜœÐ$ò 	QÜ�M‰MØ-¨c¯l©l¨^ð <2ð 2ô
 ôô !9× HÑ HÐIfÑ qÐjpÑ qÐÜ,×<Ñ<Ð=ZÑeÐ^dÑeˆIáÐ):ÀiÔPÒPð	Qús   ƒ “A-BÂBÚaudioÚtextr0   c                 óª  — d|v r&t        j                  d«       |j                  d«      }|€|€t        d«      ‚ | j                  t
        fd| j                  j                  i|¤Ž}| j                  r  | j                  |fi |d   ¤|d   ¤|d   ¤ŽS |� | j                  |fi |d   ¤Ž}|� | j                  |fi |d   ¤Ž}|€S |€S d   d	<   |S )
a¹  
        When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
        [`~Wav2Vec2FeatureExtractor.__call__`] and returns its output. If used in the context
        [`~Wav2Vec2Processor.as_target_processor`] this method forwards all its arguments to PreTrainedTokenizer's
        [`~PreTrainedTokenizer.__call__`]. Please refer to the docstring of the above two methods for more information.
        Ú
raw_speechzLUsing `raw_speech` as a keyword argument is deprecated. Use `audio` instead.zAYou need to specify either an `audio` or `text` input to process.Útokenizer_init_kwargsÚaudio_kwargsÚtext_kwargsÚcommon_kwargsÚ	input_idsÚlabels)r+   r,   Úpopr*   Ú_merge_kwargsr   r%   Úinit_kwargsr#   r"   r!   )	r$   r1   r2   ÚimagesÚvideosr0   Úoutput_kwargsÚinputsÚ	encodingss	            r   Ú__call__zWav2Vec2Processor.__call__K   s(  € ð ˜6Ñ!Ü�M‰MÐhÔiØ—J‘J˜|Ó,ˆEàˆ=˜T˜\ÜÐ`ÓaÐaà*˜×*Ñ*Ü#ñ
à"&§.¡.×"<Ñ"<ð
ð ñ
ˆð ×*Ò*Ø)�4×)Ñ)Øñà Ñ/ðð   Ñ.ðð   Ñ0ñ	ð ð ÐØ+�T×+Ñ+¨EÑS°]À>Ñ5RÑSˆFØÐØ&˜Ÿ™ tÑL¨}¸]Ñ/KÑLˆIàˆ<ØˆMØˆ]ØÐà(¨Ñ5ˆF�8ÑØˆMr   c                 óp  — | j                   r | j                  j                  |i |¤ŽS |j                  dd«      }|j                  dd«      }t	        |«      dkD  r
|d   }|dd }|�  | j
                  j                  |g|¢­i |¤Ž}|� | j                  j                  |fi |¤Ž}|€|S |€|S |d   |d<   |S )a¯  
        When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
        [`~Wav2Vec2FeatureExtractor.pad`] and returns its output. If used in the context
        [`~Wav2Vec2Processor.as_target_processor`] this method forwards all its arguments to PreTrainedTokenizer's
        [`~PreTrainedTokenizer.pad`]. Please refer to the docstring of the above two methods for more information.
        Úinput_featuresNr:   r   r   r9   )r#   r"   Úpadr;   Úlenr!   r%   )r$   Úargsr0   rE   r:   s        r   rF   zWav2Vec2Processor.pad|   sà   € ð ×*Ò*Ø-�4×)Ñ)×-Ñ-¨tÐ>°vÑ>Ð>àŸ™Ð$4°dÓ;ˆØ—‘˜H dÓ+ˆÜˆt‹9�qŠ=Ø! !™WˆNØ˜˜�8ˆDàÐ%Ø7˜T×3Ñ3×7Ñ7¸ÐXÈÒXÐQWÑXˆNØÐØ'�T—^‘^×'Ñ'¨Ñ9°&Ñ9ˆFàˆ>Ø!Ð!ØÐ#ØˆMà'-¨kÑ':ˆN˜8Ñ$Ø!Ð!r   c                 ó:   —  | j                   j                  |i |¤ŽS )zÃ
        This method forwards all its arguments to PreTrainedTokenizer's [`~PreTrainedTokenizer.batch_decode`]. Please
        refer to the docstring of this method for more information.
        )r%   Úbatch_decode©r$   rH   r0   s      r   rJ   zWav2Vec2Processor.batch_decodeš   s    € ð
 +ˆt�~‰~×*Ñ*¨DÐ;°FÑ;Ð;r   c                 ó:   —  | j                   j                  |i |¤ŽS )z½
        This method forwards all its arguments to PreTrainedTokenizer's [`~PreTrainedTokenizer.decode`]. Please refer
        to the docstring of this method for more information.
        )r%   ÚdecoderK   s      r   rM   zWav2Vec2Processor.decode¡   s    € ð
 %ˆt�~‰~×$Ñ$ dÐ5¨fÑ5Ð5r   c              #   óž   K  — t        j                  d«       d| _        | j                  | _        d–— | j
                  | _        d| _        y­w)zŒ
        Temporarily sets the tokenizer for processing the input. Useful for encoding the labels when fine-tuning
        Wav2Vec2.
        zî`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your labels by using the argument `text` of the regular `__call__` method (either in the same call as your audio inputs, or in a separate call.TNF)r+   r,   r#   r%   r"   r!   )r$   s    r   Úas_target_processorz%Wav2Vec2Processor.as_target_processor¨   sH   è ø€ ô 	�‰ð8ô	
ð
 +/ˆÔ'Ø!%§¡ˆÔÛØ!%×!7Ñ!7ˆÔØ*/ˆÕ'ùs   ‚AA)NNNN)r   r   r   Ú__doc__Úfeature_extractor_classÚtokenizer_classr    Úclassmethodr(   r   r   r   Ústrr   r   r   r
   r   rC   rF   rJ   rM   r   rO   Ú__classcell__)r&   s   @r   r   r   !   s¡   ø„ ñð 9ÐØ%€Oô0ð
 óQó ðQð( !ØNRØØñ/àð/ð �u˜S $ s¡)¨YÐ8IÐIÑJÑKð/ð Ð0Ñ1ó/òb"ò<<ò6ð ñ0ó ô0r   r   )rP   r+   Ú
contextlibr   Útypingr   r   r   Úprocessing_utilsr   r	   r
   Útokenization_utils_baser   r   r   Úfeature_extraction_wav2vec2r   Útokenization_wav2vec2r   r   r   Ú__all__r   r   r   ú<module>r]      sR   ðñó Ý %ß (Ñ (ç HÑ Hß OÑ OÝ AÝ 7ôÐ.°eõ ôV0˜ô V0ðr Ð
�r   