

import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin



class lowerCamelCase			(  lowercase_						):



			'''simple docstring'''






			__snake_case        =	'MCTCTFeatureExtractor'
			__snake_case        =	'AutoTokenizer'


			def __init__(				self	:						Optional[Any]		,      lowerCAmelCase_	:						List[str]		,      lowerCAmelCase_	:						Optional[int]			)      ->		Any:





									'''simple docstring'''
									super().__init__(lowerCAmelCase_		,      lowerCAmelCase_			)
									A__					:       Optional[Any]     =self.feature_extractor
									A__					:       int     =False


			def __call__(				self	:						Optional[int]		,      *lowerCAmelCase_	:						Any		,      **lowerCAmelCase_	:						Tuple			)      ->		Any:





									'''simple docstring'''
									# 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."""			)
															A__					:       Optional[int]     =kwargs.pop("""raw_speech"""			)
									else:
															A__					:       Any     =kwargs.pop("""audio"""		,      lowerCAmelCase_			)
									A__					:       Dict     =kwargs.pop("""sampling_rate"""		,      lowerCAmelCase_			)
									A__					:       Any     =kwargs.pop("""text"""		,      lowerCAmelCase_			)
									if len(lowerCAmelCase_			) > 0:
															A__					:       Dict     =args[0]
															A__					:       Any     =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__					:       Any     =self.feature_extractor(lowerCAmelCase_		,      *lowerCAmelCase_		,      sampling_rate=lowerCAmelCase_		,      **lowerCAmelCase_			)
									if text is not None:
															A__					:       Tuple     =self.tokenizer(lowerCAmelCase_		,      **lowerCAmelCase_			)

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


			def lowercase__						(				self	:						Dict		,      *lowerCAmelCase_	:						Any		,      **lowerCAmelCase_	:						Dict			)      ->		int:





									'''simple docstring'''
									return self.tokenizer.batch_decode(*lowerCAmelCase_		,      **lowerCAmelCase_			)


			def lowercase__						(				self	:						List[Any]		,      *lowerCAmelCase_	:						int		,      **lowerCAmelCase_	:						int			)      ->		Tuple:





									'''simple docstring'''
									# For backward compatibility
									if self._in_target_context_manager:
															return self.current_processor.pad(*lowerCAmelCase_		,      **lowerCAmelCase_			)

									A__					:       Dict     =kwargs.pop("""input_features"""		,      lowerCAmelCase_			)
									A__					:       Any     =kwargs.pop("""labels"""		,      lowerCAmelCase_			)
									if len(lowerCAmelCase_			) > 0:
															A__					:       List[str]     =args[0]
															A__					:       Any     =args[1:]

									if input_features is not None:
															A__					:       List[str]     =self.feature_extractor.pad(lowerCAmelCase_		,      *lowerCAmelCase_		,      **lowerCAmelCase_			)
									if labels is not None:
															A__					:       Optional[Any]     =self.tokenizer.pad(lowerCAmelCase_		,      **lowerCAmelCase_			)

									if labels is None:
															return input_features
									elif input_features is None:
															return labels
									else:
															A__					:       Optional[Any]     =labels["""input_ids"""]
															return input_features


			def lowercase__						(				self	:						List[Any]		,      *lowerCAmelCase_	:						Any		,      **lowerCAmelCase_	:						List[Any]			)      ->		Any:





									'''simple docstring'''
									return self.tokenizer.decode(*lowerCAmelCase_		,      **lowerCAmelCase_			)



			@contextmanager
			def lowercase__						(				self	:						str			)      ->		Optional[Any]:





									'''simple docstring'''
									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__					:       Tuple     =True
									A__					:       int     =self.tokenizer
									yield
									A__					:       List[Any]     =self.feature_extractor
									A__					:       List[Any]     =False




'''simple docstring'''



from typing import TYPE_CHECKING

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


__snake_case			:     Any										=      {
    'configuration_audio_spectrogram_transformer': [
        'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'ASTConfig',
    ]
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case			:     Optional[int]										=      [
		    'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'ASTForAudioClassification',
		    'ASTModel',
		    'ASTPreTrainedModel',
		]

try:
		if not is_speech_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case			:     List[Any]										=      ['ASTFeatureExtractor']

if TYPE_CHECKING:
		from .configuration_audio_spectrogram_transformer import (
		    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    ASTConfig,
		)

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_audio_spectrogram_transformer import (
				    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
				    ASTForAudioClassification,
				    ASTModel,
				    ASTPreTrainedModel,
				)

		try:
				if not is_speech_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_audio_spectrogram_transformer import ASTFeatureExtractor


else:
		import sys

		__snake_case			:     Optional[Any]										=      _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

