



"""simple docstring"""





import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin


class       __lowerCamelCase	(   _a    ):
   __UpperCamelCase									=   'AutoFeatureExtractor'
   __UpperCamelCase									=   'Speech2Text2Tokenizer'







   def __init__(self       ,	lowerCamelCase       ,	lowerCamelCase				):




      '''simple docstring'''




      super().__init__(lowerCamelCase__       ,	lowerCamelCase__				)
      _lowerCAmelCase					     =		self.feature_extractor
      _lowerCAmelCase					     =		False







   def __call__(self       ,	*lowerCamelCase       ,	**lowerCamelCase				):




      '''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."""				)
         _lowerCAmelCase					     =		kwargs.pop("""raw_speech"""				)
      else:
         _lowerCAmelCase					     =		kwargs.pop("""audio"""       ,	lowerCamelCase__				)
      _lowerCAmelCase					     =		kwargs.pop("""sampling_rate"""       ,	lowerCamelCase__				)
      _lowerCAmelCase					     =		kwargs.pop("""text"""       ,	lowerCamelCase__				)
      if len(lowerCamelCase__				) > 0:
         _lowerCAmelCase					     =		args[0]
         _lowerCAmelCase					     =		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:
         _lowerCAmelCase					     =		self.feature_extractor(lowerCamelCase__       ,	*lowerCamelCase__       ,	sampling_rate=lowerCamelCase__       ,	**lowerCamelCase__				)
      if text is not None:
         _lowerCAmelCase					     =		self.tokenizer(lowerCamelCase__       ,	**lowerCamelCase__				)

      if text is None:
         return inputs
      elif audio is None:
         return encodings
      else:
         _lowerCAmelCase					     =		encodings["input_ids"]
         return inputs







   def 							A__						(self       ,	*lowerCamelCase       ,	**lowerCamelCase				):




      '''simple docstring'''




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







   def 							A__						(self       ,	*lowerCamelCase       ,	**lowerCamelCase				):




      '''simple docstring'''




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







   @contextmanager
   def 							A__						(self				):




      '''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."""				)
      _lowerCAmelCase					     =		True
      _lowerCAmelCase					     =		self.tokenizer
      yield
      _lowerCAmelCase					     =		self.feature_extractor
      _lowerCAmelCase					     =		False




"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


SCREAMING_SNAKE_CASE				:     Union[str, Any]          =	{
    '''configuration_align''': [
        '''ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''AlignConfig''',
        '''AlignTextConfig''',
        '''AlignVisionConfig''',
    ],
    '''processing_align''': ['''AlignProcessor'''],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE				:     Any          =	[
      '''ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''AlignModel''',
      '''AlignPreTrainedModel''',
      '''AlignTextModel''',
      '''AlignVisionModel''',
  ]

if TYPE_CHECKING:
  from .configuration_align import (
      ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP,
      AlignConfig,
      AlignTextConfig,
      AlignVisionConfig,
  )
  from .processing_align import AlignProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_align import (
        ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST,
        AlignModel,
        AlignPreTrainedModel,
        AlignTextModel,
        AlignVisionModel,
    )

else:
  import sys

  SCREAMING_SNAKE_CASE				:     Any          =	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)