


import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin




class       lowercase_					(lowercase_   ):
				snake_case	    ='''Speech2TextFeatureExtractor'''
				snake_case	    ='''Speech2TextTokenizer'''





				def __init__(				self       ,  lowercase_       ,  lowercase_)  -> Dict:
											super().__init__(lowercase_       ,  lowercase_)
											a__      =self.feature_extractor
											a__      =False





				def __call__(				self       ,  *lowercase_       ,  **lowercase_)  -> List[str]:
											# For backward compatibility
											if self._in_target_context_manager:
																		return self.current_processor(*lowercase_       ,  **lowercase_)

											if "raw_speech" in kwargs:
																		warnings.warn('Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.')
																		a__      =kwargs.pop('raw_speech')
											else:
																		a__      =kwargs.pop('audio'       ,  lowercase_)
											a__      =kwargs.pop('sampling_rate'       ,  lowercase_)
											a__      =kwargs.pop('text'       ,  lowercase_)
											if len(lowercase_) > 0:
																		a__      =args[0]
																		a__      =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__      =self.feature_extractor(lowercase_       ,  *lowercase_       ,  sampling_rate=lowercase_       ,  **lowercase_)
											if text is not None:
																		a__      =self.tokenizer(lowercase_       ,  **lowercase_)

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





				def 						__UpperCamelCase    (				self       ,  *lowercase_       ,  **lowercase_)  -> List[str]:
											return self.tokenizer.batch_decode(*lowercase_       ,  **lowercase_)





				def 						__UpperCamelCase    (				self       ,  *lowercase_       ,  **lowercase_)  -> List[Any]:
											return self.tokenizer.decode(*lowercase_       ,  **lowercase_)





				@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.')
											a__      =True
											a__      =self.tokenizer
											yield
											a__      =self.feature_extractor
											a__      =False




import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import ClassLabel, Features, Value
from .base import TaskTemplate







@dataclass(frozen=lowercase_     )
class 					lowercase							(			lowercase_     ):
				# `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization
				__SCREAMING_SNAKE_CASE   :					str			     =     field(default='''text-classification'''      ,    metadata={'''include_in_asdict_even_if_is_default''': True}     )
				__SCREAMING_SNAKE_CASE   :					ClassVar[Features]			     =     Features({'''text''': Value('''string'''     )}     )
				__SCREAMING_SNAKE_CASE   :					ClassVar[Features]			     =     Features({'''labels''': ClassLabel}     )
				__SCREAMING_SNAKE_CASE   :					str			     =     "text"
				__SCREAMING_SNAKE_CASE   :					str			     =     "labels"




				def        a				(   self ,  snake_case			):
											if self.label_column not in features:
																		raise ValueError(F'''Column {self.label_column} is not present in features.'''			)
											if not isinstance(features[self.label_column] ,  snake_case			):
																		raise ValueError(F'''Column {self.label_column} is not a ClassLabel.'''			)
											snake_case_     							=       copy.deepcopy(self			)
											snake_case_     							=       self.label_schema.copy()
											snake_case_     							=       features[self.label_column]
											snake_case_     							=       label_schema
											return task_template




				@property
				def        a				(   self			):
											return {
											    self.text_column: "text",
											    self.label_column: "labels",
											}




