




# 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 						__lowerCAmelCase      (      __magic_name__					):
							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  lowerCamelCase__				(		self		:Optional[Any]						, __magic_name__		:Tuple							):







								'''simple docstring'''







								return self.pre_processor(__magic_name__						, return_tensors="""pt"""							).input_features
							def  lowerCamelCase__				(		self		:Union[str, Any]						, __magic_name__		:Any							):







								'''simple docstring'''







								return self.model.generate(inputs=__magic_name__							)





							def  lowerCamelCase__				(		self		:Any						, __magic_name__		:List[str]							):







								'''simple docstring'''







								return self.pre_processor.batch_decode(__magic_name__						, skip_special_tokens=__magic_name__							)[0]







from bisect import bisect
from itertools import accumulate





def 						__A						(      __lowerCamelCase				,     __lowerCamelCase				,     __lowerCamelCase				,     __lowerCamelCase       ) ->			Dict:
	a									=				sorted(zip(__lowerCamelCase				,     __lowerCamelCase       )				,     key=lambda __lowerCamelCase       : x[0] / x[1]				,     reverse=__lowerCamelCase       )
	a							,					a									=				[i[0] for i in r], [i[1] for i in r]
	a									=				list(accumulate(__lowerCamelCase       )       )
	a									=				bisect(__lowerCamelCase				,     __lowerCamelCase       )
	return (
	    0
	    if k == 0
	    else sum(vl[:k]       ) + (w - acc[k - 1]) * (vl[k]) / (wt[k])
	    if k != n
	    else sum(vl[:k]       )
	)


if __name__ == "__main__":
		import doctest

		doctest.testmod()

