



'''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 	lowerCamelCase_							(					snake_case_			):
						_lowerCAmelCase     :   int	     =				'openai/whisper-base'
						_lowerCAmelCase     :   List[str]	     =				(
						    'This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the '
						    'transcribed text.'
						)
						_lowerCAmelCase     :   Optional[Any]	     =				'transcriber'
						_lowerCAmelCase     :   int	     =				WhisperProcessor
						_lowerCAmelCase     :   Optional[int]	     =				WhisperForConditionalGeneration

						_lowerCAmelCase     :   str	     =				['audio']
						_lowerCAmelCase     :   int	     =				['text']







						def 					__lowercase    (  self   :      Optional[Any]				,    lowerCAmelCase__   :      List[Any]				):

													"""simple docstring"""
													return self.pre_processor(lowerCAmelCase__				,    return_tensors='''pt'''				).input_features







						def 					__lowercase    (  self   :      Optional[Any]				,    lowerCAmelCase__   :      int				):

													"""simple docstring"""
													return self.model.generate(inputs=lowerCAmelCase__				)







						def 					__lowercase    (  self   :      List[Any]				,    lowerCAmelCase__   :      Any				):

													"""simple docstring"""
													return self.pre_processor.batch_decode(lowerCAmelCase__				,    skip_special_tokens=lowerCAmelCase__				)[0]









'''simple docstring'''



import string
from math import logaa
def 					UpperCAmelCase   (						A  :				str					,		A  :				str				):
							SCREAMING_SNAKE_CASE					:      Optional[Any]     					=			document.translate(
							    str.maketrans(''''''					,		''''''					,		string.punctuation				)				).replace('''\n'''					,		''''''				)
							SCREAMING_SNAKE_CASE					:      Tuple     					=			document_without_punctuation.split(''' '''				)  # word tokenization
							return len([word for word in tokenize_document if word.lower() == term.lower()]				)
def 					UpperCAmelCase   (						A  :				str					,		A  :				str				):
							SCREAMING_SNAKE_CASE					:      int     					=			corpus.lower().translate(
							    str.maketrans(''''''					,		''''''					,		string.punctuation				)				)  # strip all punctuation and replace it with ''
							SCREAMING_SNAKE_CASE					:      Any     					=			corpus_without_punctuation.split('''\n'''				)
							SCREAMING_SNAKE_CASE					:      Optional[Any]     					=			term.lower()
							return (len([doc for doc in docs if term in doc]				), len(A				))
def 					UpperCAmelCase   (						A  :				int					,		A  :				int					,		A  :				str=False				):
							if smoothing:
														if n == 0:
																					raise ValueError('''log10(0) is undefined.'''				)
														return round(1 + logaa(n / (1 + df)				)					,		3				)

							if df == 0:
														raise ZeroDivisionError('''df must be > 0'''				)
							elif n == 0:
														raise ValueError('''log10(0) is undefined.'''				)
							return round(logaa(n / df				)					,		3				)






def 					UpperCAmelCase   (						A  :				int					,		A  :				int				):
							return round(tf * idf					,		3				)




