
    cCi                     D    S r SSKrSSKJr  SSKJr   " S S\5      rS/rg)z$
Speech processor class for M-CTC-T
    N)contextmanager   )ProcessorMixinc                   V   ^  \ rS rSrSrSrSrU 4S jrS rS r	S r
\S	 5       rS
rU =r$ )MCTCTProcessor   a7  
Constructs a MCTCT processor which wraps a MCTCT feature extractor and a MCTCT tokenizer into a single processor.

[`MCTCTProcessor`] offers all the functionalities of [`MCTCTFeatureExtractor`] and [`AutoTokenizer`]. See the
[`~MCTCTProcessor.__call__`] and [`~MCTCTProcessor.decode`] for more information.

Args:
    feature_extractor (`MCTCTFeatureExtractor`):
        An instance of [`MCTCTFeatureExtractor`]. The feature extractor is a required input.
    tokenizer (`AutoTokenizer`):
        An instance of [`AutoTokenizer`]. The tokenizer is a required input.
MCTCTFeatureExtractorAutoTokenizerc                 T   > [         TU ]  X5        U R                  U l        SU l        g )NF)super__init__feature_extractorcurrent_processor_in_target_context_manager)selfr   	tokenizer	__class__s      o/home/james-whalen/.local/lib/python3.13/site-packages/transformers/models/deprecated/mctct/processing_mctct.pyr   MCTCTProcessor.__init__*   s'    *6!%!7!7*/'    c                    U R                   (       a  U R                  " U0 UD6$ SU;   a(  [        R                  " S5        UR	                  S5      nOUR	                  SS5      nUR	                  SS5      nUR	                  SS5      n[        U5      S:  a
  US   nUSS nUc  Uc  [        S	5      eUb  U R                  " U/UQ7SU0UD6nUb  U R                  " U40 UD6nUc  W$ Uc  W$ WS
   WS'   U$ )a|  
When used in normal mode, this method forwards all its arguments to MCTCTFeatureExtractor's
[`~MCTCTFeatureExtractor.__call__`] and returns its output. If used in the context
[`~MCTCTProcessor.as_target_processor`] this method forwards all its arguments to AutoTokenizer's
[`~AutoTokenizer.__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.audioNsampling_ratetextr      zAYou need to specify either an `audio` or `text` input to process.	input_idslabels)	r   r   warningswarnpoplen
ValueErrorr   r   )r   argskwargsr   r   r   inputs	encodingss           r   __call__MCTCTProcessor.__call__/   s    **))4:6::6!MMhiJJ|,EJJw-E

?D9zz&$'t9q=GE8D=T\`aa++E`D``Y_`Ft6v6I<M](5F8Mr   c                    U R                   (       a  U R                  R                  " U0 UD6$ UR                  SS5      nUR                  SS5      n[	        U5      S:  a
  US   nUSS nUb   U R
                  R                  " U/UQ70 UD6nUb  U R                  R                  " U40 UD6nUc  U$ Uc  U$ US   US'   U$ )a~  
When used in normal mode, this method forwards all its arguments to MCTCTFeatureExtractor's
[`~MCTCTFeatureExtractor.pad`] and returns its output. If used in the context
[`~MCTCTProcessor.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   r   )r   r   padr!   r"   r   r   )r   r$   r%   r+   r   s        r   r,   MCTCTProcessor.padU   s     **))--t>v>>$4d;Hd+t9q=!!WN8D%!3377XXQWXN^^''9&9F>!!#M'-k':N8$!!r   c                 :    U R                   R                  " U0 UD6$ )z
This method forwards all its arguments to AutoTokenizer's [`~PreTrainedTokenizer.decode`]. Please refer to the
docstring of this method for more information.
)r   decode)r   r$   r%   s      r   r/   MCTCTProcessor.decodes   s    
 ~~$$d5f55r   c              #      #    [         R                  " S5        SU l        U R                  U l        Sv   U R
                  U l        SU l        g7f)zq
Temporarily sets the tokenizer for processing the input. Useful for encoding the labels when fine-tuning MCTCT.
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_processor"MCTCTProcessor.as_target_processorz   sG     
 	8	

 +/'!%!%!7!7*/'s   AA)r   r   )__name__
__module____qualname____firstlineno____doc__feature_extractor_classtokenizer_classr   r(   r,   r/   r   r2   __static_attributes____classcell__)r   s   @r   r   r      s>     6%O0
$L"<6 0 0r   r   )r8   r   
contextlibr   processing_utilsr   r   __all__ r   r   <module>rA      s.     % /o0^ o0d 
r   