




import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
from .feature_extraction_wavaveca import WavaVecaFeatureExtractor
from .tokenization_wavaveca import WavaVecaCTCTokenizer
class 			_UpperCamelCase      (				lowerCAmelCase		):
      UpperCAmelCase_        =		"""Wav2Vec2FeatureExtractor"""
      UpperCAmelCase_        =		"""AutoTokenizer"""
      def __init__(			self   :List[str] ,      lowerCamelCase   :str ,      lowerCamelCase   :List[Any]      )     ->			Union[str, Any]:
       super().__init__(lowerCamelCase ,      lowerCamelCase      )
       UpperCAmelCase__							 =						self.feature_extractor
       UpperCAmelCase__							 =						False
      @classmethod
      def 	UpperCAmelCase_						(			cls   :List[Any] ,      lowerCamelCase   :Any ,      **lowerCamelCase   :Union[str, Any]      )     ->			Optional[int]:
       try:
        return super().from_pretrained(lowerCamelCase ,      **lowerCamelCase      )
       except OSError:
        warnings.warn(
            f'''Loading a tokenizer inside {cls.__name__} from a config that does not'''
            " include a `tokenizer_class` attribute is deprecated and will be "
            "removed in v5. Please add `'tokenizer_class': 'Wav2Vec2CTCTokenizer'`"
            " attribute to either your `config.json` or `tokenizer_config.json` "
            "file to suppress this warning: " ,      lowerCamelCase ,      )

        UpperCAmelCase__							 =						WavaVecaFeatureExtractor.from_pretrained(lowerCamelCase ,      **lowerCamelCase      )
        UpperCAmelCase__							 =						WavaVecaCTCTokenizer.from_pretrained(lowerCamelCase ,      **lowerCamelCase      )

        return cls(feature_extractor=lowerCamelCase ,      tokenizer=lowerCamelCase      )
      def __call__(			self   :List[Any] ,      *lowerCamelCase   :Optional[int] ,      **lowerCamelCase   :Dict      )     ->			str:
       # For backward compatibility
       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."      )
        UpperCAmelCase__							 =						kwargs.pop("raw_speech"      )
       else:
        UpperCAmelCase__							 =						kwargs.pop("audio" ,      lowerCamelCase      )
       UpperCAmelCase__							 =						kwargs.pop("sampling_rate" ,      lowerCamelCase      )
       UpperCAmelCase__							 =						kwargs.pop("text" ,      lowerCamelCase      )
       if len(lowerCamelCase      ) > 0:
        UpperCAmelCase__							 =						args[0]
        UpperCAmelCase__							 =						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:
        UpperCAmelCase__							 =						self.feature_extractor(lowerCamelCase ,      *lowerCamelCase ,      sampling_rate=lowerCamelCase ,      **lowerCamelCase      )
       if text is not None:
        UpperCAmelCase__							 =						self.tokenizer(lowerCamelCase ,      **lowerCamelCase      )

       if text is None:
        return inputs
       elif audio is None:
        return encodings
       else:
        UpperCAmelCase__							 =						encodings["input_ids"]
        return inputs
      def 	UpperCAmelCase_						(			self   :Any ,      *lowerCamelCase   :List[Any] ,      **lowerCamelCase   :Dict      )     ->			Dict:
       # For backward compatibility
       if self._in_target_context_manager:
        return self.current_processor.pad(*lowerCamelCase ,      **lowerCamelCase      )

       UpperCAmelCase__							 =						kwargs.pop("input_features" ,      lowerCamelCase      )
       UpperCAmelCase__							 =						kwargs.pop("labels" ,      lowerCamelCase      )
       if len(lowerCamelCase      ) > 0:
        UpperCAmelCase__							 =						args[0]
        UpperCAmelCase__							 =						args[1:]

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

       if labels is None:
        return input_features
       elif input_features is None:
        return labels
       else:
        UpperCAmelCase__							 =						labels["input_ids"]
        return input_features
      def 	UpperCAmelCase_						(			self   :List[Any] ,      *lowerCamelCase   :List[str] ,      **lowerCamelCase   :Dict      )     ->			str:
       return self.tokenizer.batch_decode(*lowerCamelCase ,      **lowerCamelCase      )
      def 	UpperCAmelCase_						(			self   :Union[str, Any] ,      *lowerCamelCase   :Optional[Any] ,      **lowerCamelCase   :Optional[int]      )     ->			Optional[Any]:
       return self.tokenizer.decode(*lowerCamelCase ,      **lowerCamelCase      )







      @contextmanager
      def 	UpperCAmelCase_						(			self   :Optional[Any]      )     ->			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."      )
       UpperCAmelCase__							 =						True
       UpperCAmelCase__							 =						self.tokenizer
       yield
       UpperCAmelCase__							 =						self.feature_extractor
       UpperCAmelCase__							 =						False











from ..utils import DummyObject, requires_backends
class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :List[Any] ,      *lowerCamelCase   :int ,      **lowerCamelCase   :List[Any]      )     ->			Dict:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :Union[str, Any] ,      *lowerCamelCase   :Any ,      **lowerCamelCase   :List[str]      )     ->			int:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :Optional[int] ,      *lowerCamelCase   :List[str] ,      **lowerCamelCase   :List[Any]      )     ->			Dict:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :Dict ,      *lowerCamelCase   :int ,      **lowerCamelCase   :str      )     ->			str:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :Optional[int] ,      *lowerCamelCase   :Tuple ,      **lowerCamelCase   :List[Any]      )     ->			Optional[int]:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :Optional[Any] ,      *lowerCamelCase   :Dict ,      **lowerCamelCase   :Optional[int]      )     ->			List[Any]:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :List[str] ,      *lowerCamelCase   :Union[str, Any] ,      **lowerCamelCase   :Any      )     ->			Union[str, Any]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :List[Any] ,      *lowerCamelCase   :str ,      **lowerCamelCase   :List[Any]      )     ->			Tuple:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :str ,      *lowerCamelCase   :Any ,      **lowerCamelCase   :Dict      )     ->			int:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :Union[str, Any] ,      *lowerCamelCase   :int ,      **lowerCamelCase   :Dict      )     ->			List[Any]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :int ,      *lowerCamelCase   :Union[str, Any] ,      **lowerCamelCase   :str      )     ->			Optional[int]:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :List[str] ,      *lowerCamelCase   :Optional[int] ,      **lowerCamelCase   :Tuple      )     ->			Dict:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :Union[str, Any] ,      *lowerCamelCase   :Any ,      **lowerCamelCase   :List[str]      )     ->			Union[str, Any]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :Optional[Any] ,      *lowerCamelCase   :Union[str, Any] ,      **lowerCamelCase   :Optional[Any]      )     ->			Optional[int]:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :List[Any] ,      *lowerCamelCase   :Dict ,      **lowerCamelCase   :Optional[int]      )     ->			List[str]:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :Tuple ,      *lowerCamelCase   :str ,      **lowerCamelCase   :List[str]      )     ->			List[Any]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :Any ,      *lowerCamelCase   :List[str] ,      **lowerCamelCase   :Any      )     ->			int:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :List[Any] ,      *lowerCamelCase   :List[Any] ,      **lowerCamelCase   :Optional[Any]      )     ->			Tuple:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :Any ,      *lowerCamelCase   :List[Any] ,      **lowerCamelCase   :List[str]      )     ->			List[str]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :Optional[Any] ,      *lowerCamelCase   :Optional[int] ,      **lowerCamelCase   :Dict      )     ->			Union[str, Any]:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :int ,      *lowerCamelCase   :List[Any] ,      **lowerCamelCase   :str      )     ->			str:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :str ,      *lowerCamelCase   :Any ,      **lowerCamelCase   :Union[str, Any]      )     ->			Optional[Any]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :Optional[Any] ,      *lowerCamelCase   :Any ,      **lowerCamelCase   :List[str]      )     ->			int:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :List[Any] ,      *lowerCamelCase   :Union[str, Any] ,      **lowerCamelCase   :Union[str, Any]      )     ->			List[Any]:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :Dict ,      *lowerCamelCase   :Dict ,      **lowerCamelCase   :int      )     ->			List[Any]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :Tuple ,      *lowerCamelCase   :Optional[Any] ,      **lowerCamelCase   :Optional[int]      )     ->			Dict:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :Any ,      *lowerCamelCase   :Optional[int] ,      **lowerCamelCase   :List[str]      )     ->			List[Any]:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :List[Any] ,      *lowerCamelCase   :int ,      **lowerCamelCase   :Optional[Any]      )     ->			List[str]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :int ,      *lowerCamelCase   :List[Any] ,      **lowerCamelCase   :List[Any]      )     ->			Any:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :str ,      *lowerCamelCase   :Optional[int] ,      **lowerCamelCase   :str      )     ->			List[str]:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :List[Any] ,      *lowerCamelCase   :str ,      **lowerCamelCase   :int      )     ->			List[Any]:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :List[str] ,      *lowerCamelCase   :List[Any] ,      **lowerCamelCase   :Any      )     ->			List[Any]:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :Optional[Any] ,      *lowerCamelCase   :Any ,      **lowerCamelCase   :Tuple      )     ->			int:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :Any ,      *lowerCamelCase   :List[Any] ,      **lowerCamelCase   :Tuple      )     ->			Dict:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :List[Any] ,      *lowerCamelCase   :int ,      **lowerCamelCase   :Union[str, Any]      )     ->			List[Any]:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :str ,      *lowerCamelCase   :int ,      **lowerCamelCase   :List[str]      )     ->			List[str]:
       requires_backends(cls ,      ["flax"]      )



class 			_UpperCamelCase      (				metaclass=lowerCAmelCase		):
      UpperCAmelCase_        =		["""flax"""]
      def __init__(			self   :int ,      *lowerCamelCase   :Dict ,      **lowerCamelCase   :Optional[int]      )     ->			str:
       requires_backends(self ,      ["flax"]      )
      @classmethod
      def 	UpperCAmelCase_						(			cls   :Union[str, Any] ,      *lowerCamelCase   :Any ,      **lowerCamelCase   :Union[str, Any]      )     ->			Optional[int]:
       requires_backends(cls ,      ["flax"]      )







      @classmethod
      def 	UpperCAmelCase_						(			cls   :int ,      *lowerCamelCase   :Union[str, Any] ,      **lowerCamelCase   :Any      )     ->			Optional[Any]:
       requires_backends(cls ,      ["flax"]      )





