



import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin



class 						UpperCAmelCase_					( snake_case_):
							lowerCamelCase__         =	"""Speech2TextFeatureExtractor"""
							lowerCamelCase__         =	"""Speech2TextTokenizer"""







							def __init__(     self,    __a,    __a):

														'''simple docstring'''

														super().__init__(__a,    __a)
														_lowerCAmelCase  :							List[str]				     =					self.feature_extractor
														_lowerCAmelCase  :							int				     =					False







							def __call__(     self,    *__a,    **__a):

														'''simple docstring'''

														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.")
																					_lowerCAmelCase  :							List[Any]				     =					kwargs.pop("raw_speech")
														else:
																					_lowerCAmelCase  :							List[str]				     =					kwargs.pop("audio",    __a)
														_lowerCAmelCase  :							Optional[Any]				     =					kwargs.pop("sampling_rate",    __a)
														_lowerCAmelCase  :							str				     =					kwargs.pop("text",    __a)
														if len(__a) > 0:
																					_lowerCAmelCase  :							str				     =					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  :							Any				     =					self.feature_extractor(__a,    *__a,    sampling_rate=__a,    **__a)
														if text is not None:
																					_lowerCAmelCase  :							Union[str, Any]				     =					self.tokenizer(__a,    **__a)

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







							def      snake_case__   (     self,    *__a,    **__a):

														'''simple docstring'''

														return self.tokenizer.batch_decode(*__a,    **__a)







							def      snake_case__   (     self,    *__a,    **__a):

														'''simple docstring'''

														return self.tokenizer.decode(*__a,    **__a)







							@contextmanager
							def      snake_case__   (     self):

														'''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.")
														_lowerCAmelCase  :							Tuple				     =					True
														_lowerCAmelCase  :							Dict				     =					self.tokenizer
														yield
														_lowerCAmelCase  :							Dict				     =					self.feature_extractor
														_lowerCAmelCase  :							Union[str, Any]				     =					False





from __future__ import annotations






def        A       (      _lowerCamelCase						):





							'''simple docstring'''




							if not nums:
														raise ValueError("List is empty"						)
							return sum(_lowerCamelCase						) / len(_lowerCamelCase						)


if __name__ == "__main__":
						import doctest

						doctest.testmod()
