

import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin



class     lowercase_       (    __lowercase	):
      UpperCamelCase_     :						str		 =							"AutoFeatureExtractor"
      UpperCamelCase_     :						Optional[Any]		 =							"Speech2Text2Tokenizer"



      def __init__(     self :							Optional[Any]     ,   A__ :							Any     ,   A__ :							Union[str, Any]						)       ->	List[str]:
        super().__init__(A__     ,   A__						)
        _snake_case		=				self.feature_extractor
        _snake_case		=				False



      def __call__(     self :							str     ,   *A__ :							List[str]     ,   **A__ :							Optional[int]						)       ->	List[Any]:
        # For backward compatibility
        if self._in_target_context_manager:
          return self.current_processor(*A__     ,   **A__						)

        if "raw_speech" in kwargs:
          warnings.warn('''Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'''						)
          _snake_case		=				kwargs.pop('''raw_speech'''						)
        else:
          _snake_case		=				kwargs.pop('''audio'''     ,   A__						)
        _snake_case		=				kwargs.pop('''sampling_rate'''     ,   A__						)
        _snake_case		=				kwargs.pop('''text'''     ,   A__						)
        if len(A__						) > 0:
          _snake_case		=				args[0]
          _snake_case		=				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:
          _snake_case		=				self.feature_extractor(A__     ,   *A__     ,   sampling_rate=A__     ,   **A__						)
        if text is not None:
          _snake_case		=				self.tokenizer(A__     ,   **A__						)

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



      def 		UpperCamelCase_						(     self :							str     ,   *A__ :							str     ,   **A__ :							Tuple						)       ->	Tuple:
        return self.tokenizer.batch_decode(*A__     ,   **A__						)



      def 		UpperCamelCase_						(     self :							int     ,   *A__ :							Any     ,   **A__ :							List[str]						)       ->	str:
        return self.tokenizer.decode(*A__     ,   **A__						)







      @contextmanager
      def 		UpperCamelCase_						(     self :							Any						)       ->	Dict:
        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.'''						)
        _snake_case		=				True
        _snake_case		=				self.tokenizer
        yield
        _snake_case		=				self.feature_extractor
        _snake_case		=				False




from typing import TYPE_CHECKING

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


__A     						=      {'''configuration_hubert''': ['''HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''HubertConfig''']}

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


try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A     						=      [
     '''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     						=      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)

