
     `i                     8    d Z ddlmZ  G d de          ZdgZdS )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                 r    t                                          ||           | j        | _        d| _        d S )NF)super__init__feature_extractorcurrent_processor_in_target_context_manager)selfr   	tokenizer	__class__s      /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/transformers/models/whisper/processing_whisper.pyr   zWhisperProcessor.__init__(   s7    *I666!%!7*/'''    NTc                 <    | 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oor   c                    | j         r | j        |i |S |                    dd          }|                    dd          }|                    dd          }t          |          dk    r|d         }|dd         }||t	          d          | | j        |g|R 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9zz&$''t99q==GE8D=T\`aaa+T+E`D````Y_``F&t66v66I<M](5F8Mr   npr   c                 :    | j                             ||          S )N)return_tensors)r   get_prompt_ids)r   r   r+   s      r   r,   zWhisperProcessor.get_prompt_idsR   s    ~,,T.,QQQr   )NNT)r)   )__name__
__module____qualname____doc__feature_extractor_classtokenizer_classr   r   r(   strr,   __classcell__)r   s   @r   r   r      s          8BO0 0 0 0 0
p p p p     DR R3 R R R R R R R Rr   r   N)r0   processing_utilsr   r   __all__ r   r   <module>r8      sd     / . . . . .=R =R =R =R =R~ =R =R =R@ 
r   