
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Features, Sequence, Value
from .base import TaskTemplate





@dataclass(frozen=__SCREAMING_SNAKE_CASE    )
class 				UpperCAmelCase (    __SCREAMING_SNAKE_CASE    ):




	'''simple docstring'''





	snake_case_          =	field(default="question-answering-extractive"     ,     metadata={"include_in_asdict_even_if_is_default": True}    )
	snake_case_          =	Features({"question": Value("string"    ), "context": Value("string"    )}    )
	snake_case_          =	Features(
	    {
	        "answers": Sequence(
	            {
	                "text": Value("string"    ),
	                "answer_start": Value("int32"    ),
	            }    )
	    }    )
	snake_case_          =	"question"
	snake_case_          =	"context"
	snake_case_          =	"answers"






	@property
	def 							UpperCamelCase_    (			self   :					int					):
					return {self.question_column: "question", self.context_column: "context", self.answers_column: "answers"}





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

   A__		:	List[str]           =  ['''audio''']
   A__		:	Optional[int]           =  ['''text''']



   def    __UpperCAmelCase    (       self    :	Tuple							,       __lowerCamelCase    :	List[Any]				):



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



   def    __UpperCAmelCase    (       self    :	Optional[int]							,       __lowerCamelCase    :	List[str]				):



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





   def    __UpperCAmelCase    (       self    :	List[str]							,       __lowerCamelCase    :	int				):



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





