





import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin

class       __A     (						a    ):
    __A      =				"""MCTCTFeatureExtractor"""
    __A      =				"""AutoTokenizer"""


    def __init__(		self   , UpperCAmelCase_   , UpperCAmelCase_							):
        super().__init__(UpperCAmelCase_   , UpperCAmelCase_							)
        lowerCamelCase	 =self.feature_extractor
        lowerCamelCase	 =False


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

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


    def _snake_case       (		self   , *UpperCAmelCase_   , **UpperCAmelCase_							):
        return self.tokenizer.batch_decode(*UpperCAmelCase_   , **UpperCAmelCase_							)


    def _snake_case       (		self   , *UpperCAmelCase_   , **UpperCAmelCase_							):
        # For backward compatibility
        if self._in_target_context_manager:
            return self.current_processor.pad(*UpperCAmelCase_   , **UpperCAmelCase_							)

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

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

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


    def _snake_case       (		self   , *UpperCAmelCase_   , **UpperCAmelCase_							):
        return self.tokenizer.decode(*UpperCAmelCase_   , **UpperCAmelCase_							)


    @contextmanager
    def _snake_case       (		self							):
        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	 =True
        lowerCamelCase	 =self.tokenizer
        yield
        lowerCamelCase	 =self.feature_extractor
        lowerCamelCase	 =False












from abc import ABC, abstractmethod
from argparse import ArgumentParser

class       __A     (						a    ):


				@staticmethod
				@abstractmethod
				def _snake_case       (		UpperCAmelCase_							):
								raise NotImplementedError()


				@abstractmethod
				def _snake_case       (		self							):
								raise NotImplementedError()





