


"""simple docstring"""





import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin

class  lowercase_  ( __UpperCAmelCase						):
      __magic_name__     :							str          =				"""AutoFeatureExtractor"""
      __magic_name__     :							List[str]          =				"""Speech2Text2Tokenizer"""







      def __init__(      self :							List[Any]		,  _lowercase :							List[Any]		,  _lowercase :							int    ):
        super().__init__(lowercase_		,  lowercase_    )
        lowerCAmelCase__    :    Any								=					self.feature_extractor
        lowerCAmelCase__    :    Optional[int]								=					False







      def __call__(      self :							Optional[int]		,  *_lowercase :							int		,  **_lowercase :							str    ):

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

        if "raw_speech" in kwargs:
          warnings.warn("Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."    )
          lowerCAmelCase__    :    int								=					kwargs.pop("raw_speech"    )
        else:
          lowerCAmelCase__    :    Optional[Any]								=					kwargs.pop("audio"		,  lowercase_    )
        lowerCAmelCase__    :    List[Any]								=					kwargs.pop("sampling_rate"		,  lowercase_    )
        lowerCAmelCase__    :    Dict								=					kwargs.pop("text"		,  lowercase_    )
        if len(lowercase_    ) > 0:
          lowerCAmelCase__    :    List[str]								=					args[0]
          lowerCAmelCase__    :    int								=					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__    :    Optional[int]								=					self.feature_extractor(lowercase_		,  *lowercase_		,  sampling_rate=lowercase_		,  **lowercase_    )
        if text is not None:
          lowerCAmelCase__    :    Any								=					self.tokenizer(lowercase_		,  **lowercase_    )

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







      def 				_lowerCAmelCase       (      self :							Optional[Any]		,  *_lowercase :							List[str]		,  **_lowercase :							List[Any]    ):
        return self.tokenizer.batch_decode(*lowercase_		,  **lowercase_    )







      def 				_lowerCAmelCase       (      self :							Tuple		,  *_lowercase :							Optional[int]		,  **_lowercase :							Union[str, Any]    ):
        return self.tokenizer.decode(*lowercase_		,  **lowercase_    )







      @contextmanager
      def 				_lowerCAmelCase       (      self :							Union[str, Any]    ):
        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__    :    Union[str, Any]								=					True
        lowerCAmelCase__    :    Dict								=					self.tokenizer
        yield
        lowerCAmelCase__    :    Optional[int]								=					self.feature_extractor
        lowerCAmelCase__    :    List[str]								=					False




"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__UpperCAmelCase    				=      {"configuration_sew_d": ["SEW_D_PRETRAINED_CONFIG_ARCHIVE_MAP", "SEWDConfig"]}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __UpperCAmelCase    				=      [
       "SEW_D_PRETRAINED_MODEL_ARCHIVE_LIST",
       "SEWDForCTC",
       "SEWDForSequenceClassification",
       "SEWDModel",
       "SEWDPreTrainedModel",
   ]

if TYPE_CHECKING:
   from .configuration_sew_d import SEW_D_PRETRAINED_CONFIG_ARCHIVE_MAP, SEWDConfig

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_sew_d import (
          SEW_D_PRETRAINED_MODEL_ARCHIVE_LIST,
          SEWDForCTC,
          SEWDForSequenceClassification,
          SEWDModel,
          SEWDPreTrainedModel,
      )


else:
   import sys

   __UpperCAmelCase    				=      _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
