





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

       _UpperCamelCase				:					Union[str, Any]         =   ['''audio''']
       _UpperCamelCase				:					List[Any]         =   ['''text''']

       def lowercase (		self: List[str]					,   _SCREAMING_SNAKE_CASE: Tuple		)       -> str:




              """simple docstring"""


              return self.pre_processor(_SCREAMING_SNAKE_CASE					,   return_tensors="pt"		).input_features

       def lowercase (		self: List[str]					,   _SCREAMING_SNAKE_CASE: Dict		)       -> Optional[Any]:




              """simple docstring"""


              return self.model.generate(inputs=_SCREAMING_SNAKE_CASE		)



       def lowercase (		self: Optional[int]					,   _SCREAMING_SNAKE_CASE: List[Any]		)       -> Optional[Any]:




              """simple docstring"""


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








from ...configuration_utils import PretrainedConfig
from ...utils import logging


_UpperCAmelCase        =				logging.get_logger(__name__)

_UpperCAmelCase        =				{'openai-gpt': 'https://huggingface.co/openai-gpt/resolve/main/config.json'}



class 							_UpperCamelCase					(	lowerCAmelCase_     ):
       _UpperCamelCase				:					List[str]         =   '''openai-gpt'''
       _UpperCamelCase				:					List[str]         =   {
           '''max_position_embeddings''': '''n_positions''',
           '''hidden_size''': '''n_embd''',
           '''num_attention_heads''': '''n_head''',
           '''num_hidden_layers''': '''n_layer''',
       }

       def __init__(		self: int					,   _SCREAMING_SNAKE_CASE: int=40478					,   _SCREAMING_SNAKE_CASE: Optional[Any]=512					,   _SCREAMING_SNAKE_CASE: List[Any]=768					,   _SCREAMING_SNAKE_CASE: str=12					,   _SCREAMING_SNAKE_CASE: Any=12					,   _SCREAMING_SNAKE_CASE: Optional[int]="gelu"					,   _SCREAMING_SNAKE_CASE: int=0.1					,   _SCREAMING_SNAKE_CASE: Optional[int]=0.1					,   _SCREAMING_SNAKE_CASE: Union[str, Any]=0.1					,   _SCREAMING_SNAKE_CASE: Any=1e-5					,   _SCREAMING_SNAKE_CASE: Tuple=0.02					,   _SCREAMING_SNAKE_CASE: str="cls_index"					,   _SCREAMING_SNAKE_CASE: Union[str, Any]=True					,   _SCREAMING_SNAKE_CASE: List[Any]=None					,   _SCREAMING_SNAKE_CASE: List[Any]=True					,   _SCREAMING_SNAKE_CASE: List[Any]=0.1					,   **_SCREAMING_SNAKE_CASE: List[Any]					,   )       -> int:




              """simple docstring"""


              UpperCamelCase_          =  vocab_size
              UpperCamelCase_          =  n_positions
              UpperCamelCase_          =  n_embd
              UpperCamelCase_          =  n_layer
              UpperCamelCase_          =  n_head
              UpperCamelCase_          =  afn
              UpperCamelCase_          =  resid_pdrop
              UpperCamelCase_          =  embd_pdrop
              UpperCamelCase_          =  attn_pdrop
              UpperCamelCase_          =  layer_norm_epsilon
              UpperCamelCase_          =  initializer_range
              UpperCamelCase_          =  summary_type
              UpperCamelCase_          =  summary_use_proj
              UpperCamelCase_          =  summary_activation
              UpperCamelCase_          =  summary_first_dropout
              UpperCamelCase_          =  summary_proj_to_labels
              super().__init__(**_SCREAMING_SNAKE_CASE		)

