
    h                     0    d Z ddlmZ  G d de      ZdgZy)z$
Speech processor class for Whisper
   )ProcessorMixinc                   F     e Zd ZdZdZdZ fdZd	dZd Zd
de	fdZ
 xZS )WhisperProcessoraz  
    Constructs a Whisper processor which wraps a Whisper feature extractor and a Whisper tokenizer into a single
    processor.

    [`WhisperProcessor`] offers all the functionalities of [`WhisperFeatureExtractor`] and [`WhisperTokenizer`]. See
    the [`~WhisperProcessor.__call__`] and [`~WhisperProcessor.decode`] for more information.

    Args:
        feature_extractor (`WhisperFeatureExtractor`):
            An instance of [`WhisperFeatureExtractor`]. The feature extractor is a required input.
        tokenizer (`WhisperTokenizer`):
            An instance of [`WhisperTokenizer`]. The tokenizer is a required input.
    WhisperFeatureExtractor)WhisperTokenizerWhisperTokenizerFastc                 V    t         |   ||       | j                  | _        d| _        y )NF)super__init__feature_extractorcurrent_processor_in_target_context_manager)selfr   	tokenizer	__class__s      l/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/transformers/models/whisper/processing_whisper.pyr   zWhisperProcessor.__init__(   s)    *I6!%!7!7*/'    c                 >    | j                   j                  |||      S )N)tasklanguageno_timestamps)r   get_decoder_prompt_ids)r   r   r   r   s       r   r   z'WhisperProcessor.get_decoder_prompt_ids-   s    ~~44$an4oor   c                 z   | j                   r | j                  |i |S |j                  dd      }|j                  dd      }|j                  dd      }t        |      dkD  r
|d   }|dd }||t	        d      | | j
                  |g|d|i|}| | j                  |fi |}|S |S d   d	<   |S )
a
  
        Forwards the `audio` argument to WhisperFeatureExtractor's [`~WhisperFeatureExtractor.__call__`] and the `text`
        argument to [`~WhisperTokenizer.__call__`]. Please refer to the docstring of the above two methods for more
        information.
        audioNsampling_ratetext       zAYou need to specify either an `audio` or `text` input to process.	input_idslabels)r   r   poplen
ValueErrorr   r   )r   argskwargsr   r   r   inputs	encodingss           r   __call__zWhisperProcessor.__call__0   s     **)4))4:6::

7D)

?D9zz&$'t9q=GE8D=T\`aa+T++E`D``Y_`F&t6v6I<M](5F8Mr   r   c                 <    | j                   j                  ||      S )N)return_tensors)r   get_prompt_ids)r   r   r*   s      r   r+   zWhisperProcessor.get_prompt_idsR   s    ~~,,T.,QQr   )NNT)np)__name__
__module____qualname____doc__feature_extractor_classtokenizer_classr   r   r(   strr+   __classcell__)r   s   @r   r   r      s4     8BO0
p DR3 Rr   r   N)r0   processing_utilsr   r   __all__ r   r   <module>r8      s(    /=R~ =R@ 
r   