"""simple docstring"""


import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin






class    a__    (   _a	):
   snake_case_							=      "MCTCTFeatureExtractor"
   snake_case_							=      "AutoTokenizer"


   def __init__(     self,				_UpperCAmelCase,				_UpperCAmelCase  ):
        '''simple docstring'''



        super().__init__(_UpperCAmelCase,				_UpperCAmelCase  )
        lowercase__				 =							self.feature_extractor
        lowercase__				 =							False


   def __call__(     self,				*_UpperCAmelCase,				**_UpperCAmelCase  ):
        '''simple docstring'''



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

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


   def 	snake_case__	(     self,				*_UpperCAmelCase,				**_UpperCAmelCase  ):
        '''simple docstring'''



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


   def 	snake_case__	(     self,				*_UpperCAmelCase,				**_UpperCAmelCase  ):
        '''simple docstring'''



        if self._in_target_context_manager:
             return self.current_processor.pad(*_UpperCAmelCase,				**_UpperCAmelCase  )

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

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

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


   def 	snake_case__	(     self,				*_UpperCAmelCase,				**_UpperCAmelCase  ):
        '''simple docstring'''



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


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





"""simple docstring"""


from typing import Optional

from .. import Features, NamedSplit
from ..packaged_modules.text.text import Text
from ..utils.typing import NestedDataStructureLike, PathLike
from .abc import AbstractDatasetReader






class    a__    (   _a	):


   def __init__(     self,				_UpperCAmelCase,				_UpperCAmelCase = None,				_UpperCAmelCase = None,				_UpperCAmelCase = None,				_UpperCAmelCase = False,				_UpperCAmelCase = False,				_UpperCAmelCase = None,				**_UpperCAmelCase,				):
        '''simple docstring'''



        super().__init__(
            _UpperCAmelCase,				split=_UpperCAmelCase,				features=_UpperCAmelCase,				cache_dir=_UpperCAmelCase,				keep_in_memory=_UpperCAmelCase,				streaming=_UpperCAmelCase,				num_proc=_UpperCAmelCase,				**_UpperCAmelCase,				)
        lowercase__				 =							path_or_paths if isinstance(_UpperCAmelCase,				_UpperCAmelCase  ) else {self.split: path_or_paths}
        lowercase__				 =							Text(
            cache_dir=_UpperCAmelCase,				data_files=_UpperCAmelCase,				features=_UpperCAmelCase,				**_UpperCAmelCase,				)


   def 	snake_case__	(     self  ):
        '''simple docstring'''



        if self.streaming:
             lowercase__				 =							self.builder.as_streaming_dataset(split=self.split  )
        # Build regular (map-style) dataset
        else:
             lowercase__				 =							None
             lowercase__				 =							None
             lowercase__				 =							None
             lowercase__				 =							None

             self.builder.download_and_prepare(
                 download_config=_UpperCAmelCase,				download_mode=_UpperCAmelCase,				verification_mode=_UpperCAmelCase,				base_path=_UpperCAmelCase,				num_proc=self.num_proc,				)
             lowercase__				 =							self.builder.as_dataset(
                 split=self.split,				verification_mode=_UpperCAmelCase,				in_memory=self.keep_in_memory  )
        return dataset




