






from ...processing_utils import ProcessorMixin


class 			SCREAMING_SNAKE_CASE      (      a_       ):
     '''simple docstring'''


     UpperCamelCase_				:		Dict								=						"WhisperFeatureExtractor"
     UpperCamelCase_				:		Optional[int]								=						"WhisperTokenizer"


     def __init__(					self							:						str       ,			UpperCAmelCase_							:						Optional[Any]       ,			UpperCAmelCase_							:						str   ):
       super().__init__(UpperCAmelCase_       ,			UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     self.feature_extractor
       SCREAMING_SNAKE_CASE							:   str						    =     False


     def 					_A							(					self							:						Optional[int]       ,			UpperCAmelCase_							:						str=None       ,			UpperCAmelCase_							:						List[str]=None       ,			UpperCAmelCase_							:						Any=True   ):
       return self.tokenizer.get_decoder_prompt_ids(task=UpperCAmelCase_       ,			language=UpperCAmelCase_       ,			no_timestamps=UpperCAmelCase_   )


     def __call__(					self							:						Tuple       ,			*UpperCAmelCase_							:						Optional[int]       ,			**UpperCAmelCase_							:						Tuple   ):







       if self._in_target_context_manager:
         return self.current_processor(*UpperCAmelCase_       ,			**UpperCAmelCase_   )

       SCREAMING_SNAKE_CASE							:   str						    =     kwargs.pop("audio"       ,			UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   List[str]						    =     kwargs.pop("sampling_rate"       ,			UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   int						    =     kwargs.pop("text"       ,			UpperCAmelCase_   )
       if len(UpperCAmelCase_   ) > 0:
         SCREAMING_SNAKE_CASE							:   List[Any]						    =     args[0]
         SCREAMING_SNAKE_CASE							:   Tuple						    =     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:
         SCREAMING_SNAKE_CASE							:   int						    =     self.feature_extractor(UpperCAmelCase_       ,			*UpperCAmelCase_       ,			sampling_rate=UpperCAmelCase_       ,			**UpperCAmelCase_   )
       if text is not None:
         SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     self.tokenizer(UpperCAmelCase_       ,			**UpperCAmelCase_   )

       if text is None:
         return inputs

       elif audio is None:
         return encodings
       else:
         SCREAMING_SNAKE_CASE							:   Any						    =     encodings["input_ids"]
         return inputs


     def 					_A							(					self							:						int       ,			*UpperCAmelCase_							:						Any       ,			**UpperCAmelCase_							:						str   ):
       return self.tokenizer.batch_decode(*UpperCAmelCase_       ,			**UpperCAmelCase_   )


     def 					_A							(					self							:						str       ,			*UpperCAmelCase_							:						Dict       ,			**UpperCAmelCase_							:						int   ):
       return self.tokenizer.decode(*UpperCAmelCase_       ,			**UpperCAmelCase_   )






     def 					_A							(					self							:						Any       ,			UpperCAmelCase_							:						List[Any]       ,			UpperCAmelCase_							:						List[Any]="np"   ):
       return self.tokenizer.get_prompt_ids(UpperCAmelCase_       ,			return_tensors=UpperCAmelCase_   )










# Lint as: python3
import itertools
import os
import re


UpperCAmelCase   :    Any     =		re.compile(r"([A-Z]+)([A-Z][a-z])")
UpperCAmelCase   :    Optional[Any]     =		re.compile(r"([a-z\d])([A-Z])")

UpperCAmelCase   :    Optional[Any]     =		re.compile(r"(?<!_)_(?!_)")
UpperCAmelCase   :    Any     =		re.compile(r"(_{2,})")

UpperCAmelCase   :    List[Any]     =		r"^\w+(\.\w+)*$"

UpperCAmelCase   :    Any     =		r"<>:/\|?*"






def 	__lowerCamelCase						(							lowerCamelCase__		:						Tuple      ):





			'''simple docstring'''




			lowerCamelCase    		=  _uppercase_uppercase_re.sub(R"""\1_\2"""  ,							lowerCamelCase__      )
			lowerCamelCase    		=  _lowercase_uppercase_re.sub(R"""\1_\2"""  ,							lowerCamelCase__      )
			return name.lower()






def 	__lowerCamelCase						(							lowerCamelCase__		:						List[str]      ):





			'''simple docstring'''




			lowerCamelCase    		=  _single_underscore_re.split(lowerCamelCase__      )
			lowerCamelCase    		=  [_multiple_underscores_re.split(lowerCamelCase__      ) for n in name]
			return "".join(n.capitalize() for n in itertools.chain.from_iterable(lowerCamelCase__      ) if n != """"""      )






def 	__lowerCamelCase						(							lowerCamelCase__		:						Any      ):





			'''simple docstring'''




			if os.path.basename(lowerCamelCase__      ) != name:
						raise ValueError(f'Should be a dataset name, not a path: {name}'      )
			return camelcase_to_snakecase(lowerCamelCase__      )






def 	__lowerCamelCase						(							lowerCamelCase__		:						List[str]  ,							lowerCamelCase__		:						int      ):





			'''simple docstring'''




			if os.path.basename(lowerCamelCase__      ) != name:
						raise ValueError(f'Should be a dataset name, not a path: {name}'      )
			if not re.match(_split_re  ,							lowerCamelCase__      ):
						raise ValueError(f'Split name should match \'{_split_re}\'\' but got \'{split}\'.'      )
			return f'{filename_prefix_for_name(lowerCamelCase__      )}-{split}'






def 	__lowerCamelCase						(							lowerCamelCase__		:						List[Any]  ,							lowerCamelCase__		:						Optional[Any]  ,							lowerCamelCase__		:						List[Any]  ,							lowerCamelCase__		:						int=None      ):





			'''simple docstring'''




			lowerCamelCase    		=  filename_prefix_for_split(lowerCamelCase__  ,							lowerCamelCase__      )
			if filetype_suffix:
						prefix += f'.{filetype_suffix}'
			lowerCamelCase    		=  os.path.join(lowerCamelCase__  ,							lowerCamelCase__      )
			return f'{filepath}*'






def 	__lowerCamelCase						(							lowerCamelCase__		:						Dict  ,							lowerCamelCase__		:						List[Any]  ,							lowerCamelCase__		:						List[Any]  ,							lowerCamelCase__		:						int=None  ,							lowerCamelCase__		:						str=None      ):





			'''simple docstring'''




			lowerCamelCase    		=  filename_prefix_for_split(lowerCamelCase__  ,							lowerCamelCase__      )
			lowerCamelCase    		=  os.path.join(lowerCamelCase__  ,							lowerCamelCase__      )

			if shard_lengths:
						lowerCamelCase    		=  len(lowerCamelCase__      )
						lowerCamelCase    		=  [f'{prefix}-{shard_id:05d}-of-{num_shards:05d}' for shard_id in range(lowerCamelCase__      )]
						if filetype_suffix:
									lowerCamelCase    		=  [filename + f'.{filetype_suffix}' for filename in filenames]
						return filenames
			else:
						lowerCamelCase    		=  prefix
						if filetype_suffix:
									filename += f'.{filetype_suffix}'
						return [filename]

