





import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin







class     lowerCamelCase(	__snake_case  ):
     '''simple docstring'''


     __magic_name__        = "AutoFeatureExtractor"
     __magic_name__        = "Speech2Text2Tokenizer"




     def __init__(						self							,    snake_case_							,    snake_case_       ):
         super().__init__(UpperCAmelCase_							,    UpperCAmelCase_       )
         _A    =       self.feature_extractor
         _A    =       False




     def __call__(						self							,    *snake_case_							,    **snake_case_       ):
         # For backward compatibility
         if self._in_target_context_manager:
             return self.current_processor(*UpperCAmelCase_							,    **UpperCAmelCase_       )

         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'							,    UpperCAmelCase_       )
         _A    =       kwargs.pop('sampling_rate'							,    UpperCAmelCase_       )
         _A    =       kwargs.pop('text'							,    UpperCAmelCase_       )
         if len(UpperCAmelCase_       ) > 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(UpperCAmelCase_							,    *UpperCAmelCase_							,    sampling_rate=UpperCAmelCase_							,    **UpperCAmelCase_       )
         if text is not None:
             _A    =       self.tokenizer(UpperCAmelCase_							,    **UpperCAmelCase_       )

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




     def 					lowerCAmelCase__		(						self							,    *snake_case_							,    **snake_case_       ):
         return self.tokenizer.batch_decode(*UpperCAmelCase_							,    **UpperCAmelCase_       )




     def 					lowerCAmelCase__		(						self							,    *snake_case_							,    **snake_case_       ):
         return self.tokenizer.decode(*UpperCAmelCase_							,    **UpperCAmelCase_       )




     @contextmanager
     def 					lowerCAmelCase__		(						self       ):
         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












from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


__A       : Dict						    = {"configuration_hubert": ["HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "HubertConfig"]}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A       : List[str]						    = [
     "HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "HubertForCTC",
     "HubertForSequenceClassification",
     "HubertModel",
     "HubertPreTrainedModel",
 ]


try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A       : Tuple						    = [
     "TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "TFHubertForCTC",
     "TFHubertModel",
     "TFHubertPreTrainedModel",
 ]

if TYPE_CHECKING:
 from .configuration_hubert import HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, HubertConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_hubert import (
      HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      HubertForCTC,
      HubertForSequenceClassification,
      HubertModel,
      HubertPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_hubert import (
      TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFHubertForCTC,
      TFHubertModel,
      TFHubertPreTrainedModel,
  )


else:
 import sys

 __A       : Dict						    = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





