o
    ei	                     @   sj   d Z ddlmZmZmZ ddlmZmZmZ ddl	m
Z
 G dd deddZe
G d	d
 d
eZd
gZdS )z%
Speech processor class for Wav2Vec2
   )ProcessingKwargsProcessorMixinUnpack)
AudioInputPreTokenizedInput	TextInput)auto_docstringc                   @   s   e Zd Zi ZdS )Wav2Vec2ProcessorKwargsN)__name__
__module____qualname__	_defaults r   r   n/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/transformers/models/wav2vec2/processing_wav2vec2.pyr	      s    r	   F)totalc                	       sl   e Zd Z fddZe		ddedB deee B eB e	B dB de
e fddZd	d
 Zedd Z  ZS )Wav2Vec2Processorc                    s   t  || d S )N)super__init__)selffeature_extractor	tokenizer	__class__r   r   r      s   zWav2Vec2Processor.__init__Naudiotextkwargsc                 K   s   |du r|du rt d| jtfd| jji|}|dur(| j|fi |d }|dur7| j|fi |d }|du r=|S |du rC|S |d |d< |S )z
        Returns:
            This method returns the results of each `call` method. If both are used, the output is a dictionary containing the results of both.
        NzAYou need to specify either an `audio` or `text` input to process.tokenizer_init_kwargsaudio_kwargstext_kwargs	input_idslabels)
ValueError_merge_kwargsr	   r   init_kwargsr   )r   r   r   r   output_kwargsinputs	encodingsr   r   r   __call__    s&   zWav2Vec2Processor.__call__c                 O   s   | dd}| dd}t|dkr|d }|dd }|dur-| jj|g|R i |}|dur;| jj|fi |}|du rA|S |du rG|S |d |d< |S )ag  
        This method operates on batches of extracted features and/or tokenized text. It forwards all arguments to
        [`Wav2Vec2FeatureExtractor.pad`] and/or [`PreTrainedTokenizer.pad`] depending on the input modality and returns their outputs. If both modalities are passed, [`Wav2Vec2FeatureExtractor.pad`] and [`PreTrainedTokenizer.pad`] are called.

        Args:
            input_features:
                When the first argument is a dictionary containing a batch of tensors, or the `input_features` argument is present, it is passed to [`Wav2Vec2FeatureExtractor.pad`].
            labels:
                When the `label` argument is present, it is passed to [`PreTrainedTokenizer.pad`].

        Returns:
            This method returns the results of each `pad` method. If both are used, the output is a dictionary containing the results of both.
        input_featuresNr           r   )poplenr   padr   )r   argsr   r(   r    r   r   r   r-   A   s   zWav2Vec2Processor.padc                 C   s   | j j}|dg S )Nr    )r   model_input_names)r   feature_extractor_input_namesr   r   r   r/   b   s   
z#Wav2Vec2Processor.model_input_names)NN)r
   r   r   r   r   r   strlistr   r   r   r	   r'   r-   propertyr/   __classcell__r   r   r   r   r      s     !r   N)__doc__processing_utilsr   r   r   tokenization_utils_baser   r   r   utilsr   r	   r   __all__r   r   r   r   <module>   s   
M