
    g2                     2    d Z ddlmZ  G d de          ZdS )z$
Speech processor class for Whisper
   )ProcessorMixinc                   R     e Zd ZdZdZdZ fdZddZd Z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WhisperTokenizerc                 r    t                                          ||           | j        | _        d| _        d S )NF)super__init__feature_extractorcurrent_processor_in_target_context_manager)selfr   	tokenizer	__class__s      j/var/www/html/ai-engine/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 doctsring 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   c                 &     | j         j        |i |S )z
        This method forwards all its arguments to WhisperTokenizer's [`~PreTrainedTokenizer.batch_decode`]. Please
        refer to the docstring of this method for more information.
        )r   batch_decoder   r#   r$   s      r   r)   zWhisperProcessor.batch_decodeR   s    
 +t~*D;F;;;r   c                 &     | j         j        |i |S )z
        This method forwards all its arguments to WhisperTokenizer's [`~PreTrainedTokenizer.decode`]. Please refer to
        the docstring of this method for more information.
        )r   decoder*   s      r   r,   zWhisperProcessor.decodeY   s    
 %t~$d5f555r   npr   c                 :    | j                             ||          S )N)return_tensors)r   get_prompt_ids)r   r   r/   s      r   r0   zWhisperProcessor.get_prompt_ids`   s    ~,,T.,QQQr   )NNT)r-   )__name__
__module____qualname____doc__feature_extractor_classtokenizer_classr
   r   r'   r)   r,   strr0   __classcell__)r   s   @r   r   r      s          8(O0 0 0 0 0
p p p p     D< < <6 6 6R R3 R R R R R R R Rr   r   N)r4   processing_utilsr   r    r   r   <module>r;      sk     / . . . . .KR KR KR KR KR~ KR KR KR KR KRr   