
"""simple docstring"""

import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin






class 	_lowercase       (    __UpperCAmelCase		):
	lowercase_				=     'MCTCTFeatureExtractor'
	lowercase_				=     'AutoTokenizer'




	def __init__(			self		,			UpperCAmelCase_		,			UpperCAmelCase_ )		->							Optional[int]:
			super().__init__(UpperCAmelCase_		,			UpperCAmelCase_ )
			lowerCamelCase					:      Tuple          =   self.feature_extractor
			lowerCamelCase					:      Optional[int]          =   False




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

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




	def       _UpperCamelCase   (			self		,			*UpperCAmelCase_		,			**UpperCAmelCase_ )		->							Any:
			return self.tokenizer.batch_decode(*UpperCAmelCase_		,			**UpperCAmelCase_ )




	def       _UpperCamelCase   (			self		,			*UpperCAmelCase_		,			**UpperCAmelCase_ )		->							Optional[int]:
			# For backward compatibility
			if self._in_target_context_manager:
					return self.current_processor.pad(*UpperCAmelCase_		,			**UpperCAmelCase_ )

			lowerCamelCase					:      Dict          =   kwargs.pop('input_features'		,			UpperCAmelCase_ )
			lowerCamelCase					:      List[str]          =   kwargs.pop('labels'		,			UpperCAmelCase_ )
			if len(UpperCAmelCase_ ) > 0:
					lowerCamelCase					:      List[str]          =   args[0]
					lowerCamelCase					:      Optional[int]          =   args[1:]

			if input_features is not None:
					lowerCamelCase					:      Union[str, Any]          =   self.feature_extractor.pad(UpperCAmelCase_		,			*UpperCAmelCase_		,			**UpperCAmelCase_ )
			if labels is not None:
					lowerCamelCase					:      int          =   self.tokenizer.pad(UpperCAmelCase_		,			**UpperCAmelCase_ )

			if labels is None:
					return input_features
			elif input_features is None:
					return labels
			else:
					lowerCamelCase					:      List[str]          =   labels['input_ids']
					return input_features




	def       _UpperCamelCase   (			self		,			*UpperCAmelCase_		,			**UpperCAmelCase_ )		->							Dict:
			return self.tokenizer.decode(*UpperCAmelCase_		,			**UpperCAmelCase_ )




	@contextmanager
	def       _UpperCamelCase   (			self )		->							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.' )
			lowerCamelCase					:      List[Any]          =   True
			lowerCamelCase					:      Dict          =   self.tokenizer
			yield
			lowerCamelCase					:      int          =   self.feature_extractor
			lowerCamelCase					:      List[Any]          =   False








"""simple docstring"""

import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
					import ctypes
					import msvcrt  # noqa






					class 	_lowercase       (    ctypes.Structure		):
						# _fields is a specific attr expected by ctypes
						lowercase_				=     [('size', ctypes.c_int), ('visible', ctypes.c_byte)]
def 		UpperCAmelCase (		):





		'''simple docstring'''


		if os.name == "nt":
				lowerCamelCase					:      Optional[int]          =   CursorInfo()
				lowerCamelCase					:      Union[str, Any]          =   ctypes.windll.kernelaa.GetStdHandle(-11      )
				ctypes.windll.kernelaa.GetConsoleCursorInfo(a_,						ctypes.byref(a_      )      )
				lowerCamelCase					:      Dict          =   False
				ctypes.windll.kernelaa.SetConsoleCursorInfo(a_,						ctypes.byref(a_      )      )
		elif os.name == "posix":
				sys.stdout.write('\033[?25l'      )
				sys.stdout.flush()
def 		UpperCAmelCase (		):





		'''simple docstring'''


		if os.name == "nt":
				lowerCamelCase					:      List[str]          =   CursorInfo()
				lowerCamelCase					:      List[Any]          =   ctypes.windll.kernelaa.GetStdHandle(-11      )
				ctypes.windll.kernelaa.GetConsoleCursorInfo(a_,						ctypes.byref(a_      )      )
				lowerCamelCase					:      Optional[Any]          =   True
				ctypes.windll.kernelaa.SetConsoleCursorInfo(a_,						ctypes.byref(a_      )      )
		elif os.name == "posix":
				sys.stdout.write('\033[?25h'      )
				sys.stdout.flush()





@contextmanager
def 		UpperCAmelCase (		):





		'''simple docstring'''


		try:
				hide_cursor()
				yield
		finally:
				show_cursor()






