






"""simple docstring"""

# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor
from .base import PipelineTool

class 						A_							(      snake_case_  ):
				UpperCAmelCase__        =				'''openai/whisper-base'''
				UpperCAmelCase__        =				(
				    '''This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the '''
				    '''transcribed text.'''
				)
				UpperCAmelCase__        =				'''transcriber'''
				UpperCAmelCase__        =				WhisperProcessor
				UpperCAmelCase__        =				WhisperForConditionalGeneration

				UpperCAmelCase__        =				['''audio''']
				UpperCAmelCase__        =				['''text''']







				def     _snake_case					(							self							:						Optional[int]						,    __lowerCamelCase							:						List[Any]	)				->					Dict:
										return self.pre_processor(__lowerCamelCase						,    return_tensors="pt"	).input_features







				def     _snake_case					(							self							:						Union[str, Any]						,    __lowerCamelCase							:						Dict	)				->					List[str]:
										return self.model.generate(inputs=__lowerCamelCase	)







				def     _snake_case					(							self							:						int						,    __lowerCamelCase							:						int	)				->					List[str]:
										return self.pre_processor.batch_decode(__lowerCamelCase						,    skip_special_tokens=__lowerCamelCase	)[0]











"""simple docstring"""

from __future__ import annotations

from random import choice






def _lowerCAmelCase	(  __lowerCamelCase:Optional[int]   ):

						'''simple docstring'''






						return choice(__lowerCamelCase   )






def _lowerCAmelCase	(  __lowerCamelCase:list[int] ,						__lowerCamelCase:int   ):

						'''simple docstring'''






						__magic_name__            =     random_pivot(__lowerCamelCase   )

						# partition based on pivot
						# linear time
						__magic_name__            =     [e for e in lst if e < pivot]
						__magic_name__            =     [e for e in lst if e > pivot]

						# if we get lucky, pivot might be the element we want.
						# we can easily see this:
						# small (elements smaller than k)
						# + pivot (kth element)
						# + big (elements larger than k)
						if len(__lowerCamelCase   ) == k - 1:
												return pivot
						# pivot is in elements bigger than k
						elif len(__lowerCamelCase   ) < k - 1:
												return kth_number(__lowerCamelCase ,						k - len(__lowerCamelCase   ) - 1   )
						# pivot is in elements smaller than k
						else:
												return kth_number(__lowerCamelCase ,						__lowerCamelCase   )


if __name__ == "__main__":
			import doctest

			doctest.testmod()



