




import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin


class     UpperCamelCase_   (			a__					):

    '''simple docstring'''






    UpperCAmelCase__							  =				'MCTCTFeatureExtractor'
    UpperCAmelCase__							  =				'AutoTokenizer'


    def __init__(      self				:     str ,			UpperCAmelCase__				:     Tuple ,			UpperCAmelCase__				:     List[str])						->List[str]:





           '''simple docstring'''

           super().__init__(_lowerCamelCase ,			_lowerCamelCase)
           A__							=   self.feature_extractor
           A__							=   False


    def __call__(      self				:     str ,			*UpperCAmelCase__				:     Union[str, Any] ,			**UpperCAmelCase__				:     Dict)						->Optional[int]:





           '''simple docstring'''

           if self._in_target_context_manager:
                  return self.current_processor(*_lowerCamelCase ,			**_lowerCamelCase)

           if "raw_speech" in kwargs:
                  warnings.warn('''Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.''')
                  A__							=   kwargs.pop('''raw_speech''')
           else:
                  A__							=   kwargs.pop('''audio''' ,			_lowerCamelCase)
           A__							=   kwargs.pop('''sampling_rate''' ,			_lowerCamelCase)
           A__							=   kwargs.pop('''text''' ,			_lowerCamelCase)
           if len(_lowerCamelCase) > 0:
                  A__							=   args[0]
                  A__							=   args[1:]

           if audio is None and text is None:
                  raise ValueError('''You need to specify either an `audio` or `text` input to process.''')

           if audio is not None:
                  A__							=   self.feature_extractor(_lowerCamelCase ,			*_lowerCamelCase ,			sampling_rate=_lowerCamelCase ,			**_lowerCamelCase)
           if text is not None:
                  A__							=   self.tokenizer(_lowerCamelCase ,			**_lowerCamelCase)

           if text is None:
                  return inputs
           elif audio is None:
                  return encodings
           else:
                  A__							=   encodings['''input_ids''']
                  return inputs


    def 	SCREAMING_SNAKE_CASE							(      self				:     Optional[Any] ,			*UpperCAmelCase__				:     Any ,			**UpperCAmelCase__				:     Optional[Any])						->Dict:





           '''simple docstring'''

           return self.tokenizer.batch_decode(*_lowerCamelCase ,			**_lowerCamelCase)


    def 	SCREAMING_SNAKE_CASE							(      self				:     List[Any] ,			*UpperCAmelCase__				:     str ,			**UpperCAmelCase__				:     Any)						->List[Any]:





           '''simple docstring'''

           if self._in_target_context_manager:
                  return self.current_processor.pad(*_lowerCamelCase ,			**_lowerCamelCase)

           A__							=   kwargs.pop('''input_features''' ,			_lowerCamelCase)
           A__							=   kwargs.pop('''labels''' ,			_lowerCamelCase)
           if len(_lowerCamelCase) > 0:
                  A__							=   args[0]
                  A__							=   args[1:]

           if input_features is not None:
                  A__							=   self.feature_extractor.pad(_lowerCamelCase ,			*_lowerCamelCase ,			**_lowerCamelCase)
           if labels is not None:
                  A__							=   self.tokenizer.pad(_lowerCamelCase ,			**_lowerCamelCase)

           if labels is None:
                  return input_features
           elif input_features is None:
                  return labels
           else:
                  A__							=   labels['''input_ids''']
                  return input_features


    def 	SCREAMING_SNAKE_CASE							(      self				:     Dict ,			*UpperCAmelCase__				:     Dict ,			**UpperCAmelCase__				:     Optional[Any])						->Optional[int]:





           '''simple docstring'''

           return self.tokenizer.decode(*_lowerCamelCase ,			**_lowerCamelCase)





    @contextmanager
    def 	SCREAMING_SNAKE_CASE							(      self				:     Union[str, Any])						->Any:





           '''simple docstring'''

           warnings.warn(
               '''`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.''')
           A__							=   True
           A__							=   self.tokenizer
           yield
           A__							=   self.feature_extractor
           A__							=   False








class     UpperCamelCase_   :

    '''simple docstring'''






    def __init__(      self				:     List[str] ,			UpperCAmelCase__				:     int)						->Union[str, Any]:





           '''simple docstring'''

           A__							=   n
           A__							=   [None] * self.n
           A__							=   0  # index of the first element
           A__							=   0
           A__							=   0


    def __len__(      self				:     List[Any])						->int:





           '''simple docstring'''

           return self.size


    def 	SCREAMING_SNAKE_CASE							(      self				:     List[Any])						->bool:





           '''simple docstring'''

           return self.size == 0


    def 	SCREAMING_SNAKE_CASE							(      self				:     str)						->List[Any]:





           '''simple docstring'''

           return False if self.is_empty() else self.array[self.front]


    def 	SCREAMING_SNAKE_CASE							(      self				:     List[str] ,			UpperCAmelCase__				:     str)						->Any:





           '''simple docstring'''

           if self.size >= self.n:
                  raise Exception('''QUEUE IS FULL''')

           A__							=   data
           A__							=   (self.rear + 1) % self.n
           self.size += 1
           return self





    def 	SCREAMING_SNAKE_CASE							(      self				:     Union[str, Any])						->Any:





           '''simple docstring'''

           if self.size == 0:
                  raise Exception('''UNDERFLOW''')

           A__							=   self.array[self.front]
           A__							=   None
           A__							=   (self.front + 1) % self.n
           self.size -= 1
           return temp


