


"""simple docstring"""







import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
from .feature_extraction_wavaveca import WavaVecaFeatureExtractor
from .tokenization_wavaveca import WavaVecaCTCTokenizer




class 				UpperCamelCase_			(				UpperCamelCase):

	"""simple docstring"""





	snake_case__       :						Tuple					      =    "Wav2Vec2FeatureExtractor"
	snake_case__       :						Any					      =    "AutoTokenizer"




	def __init__(				self    :       Dict    ,    UpperCAmelCase__    :       List[str]    ,    UpperCAmelCase__    :       Optional[Any]     ) ->			List[Any]:
						super().__init__(UpperCAmelCase__    ,    UpperCAmelCase__     )
						__SCREAMING_SNAKE_CASE		     =       self.feature_extractor
						__SCREAMING_SNAKE_CASE		     =       False




	@classmethod
	def 						UpperCAmelCase_   (				cls    :       Dict    ,    UpperCAmelCase__    :       Any    ,    **UpperCAmelCase__    :       Dict     ) ->			List[Any]:
						try:
											return super().from_pretrained(UpperCAmelCase__    ,    **UpperCAmelCase__     )
						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: "    ,    UpperCAmelCase__    ,    )

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

											return cls(feature_extractor=UpperCAmelCase__    ,    tokenizer=UpperCAmelCase__     )




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

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




	def 						UpperCAmelCase_   (				self    :       str    ,    *UpperCAmelCase__    :       str    ,    **UpperCAmelCase__    :       Optional[Any]     ) ->			Dict:
						# For backward compatibility
						if self._in_target_context_manager:
											return self.current_processor.pad(*UpperCAmelCase__    ,    **UpperCAmelCase__     )

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

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

						if labels is None:
											return input_features
						elif input_features is None:
											return labels
						else:
											__SCREAMING_SNAKE_CASE		     =       labels["input_ids"]
											return input_features




	def 						UpperCAmelCase_   (				self    :       str    ,    *UpperCAmelCase__    :       Dict    ,    **UpperCAmelCase__    :       Any     ) ->			Union[str, Any]:
						return self.tokenizer.batch_decode(*UpperCAmelCase__    ,    **UpperCAmelCase__     )




	def 						UpperCAmelCase_   (				self    :       Optional[Any]    ,    *UpperCAmelCase__    :       Union[str, Any]    ,    **UpperCAmelCase__    :       List[Any]     ) ->			str:
						return self.tokenizer.decode(*UpperCAmelCase__    ,    **UpperCAmelCase__     )




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




"""simple docstring"""







import warnings

from ...utils import logging
from .image_processing_videomae import VideoMAEImageProcessor


a__       :							Dict        =  logging.get_logger(__name__)




class 				UpperCamelCase_			(				UpperCamelCase):

	"""simple docstring"""





	def __init__(				self    :       str    ,    *UpperCAmelCase__    :       List[Any]    ,    **UpperCAmelCase__    :       Tuple     ) ->			None:
						warnings.warn(
						    "The class VideoMAEFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
						    " Please use VideoMAEImageProcessor instead."    ,    UpperCAmelCase__    ,    )
						super().__init__(*UpperCAmelCase__    ,    **UpperCAmelCase__     )
