





from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor
from .base import PipelineTool


class   _lowercase						(							a				):
   _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    ,   _UpperCAmelCase					):
       return self.pre_processor(_UpperCAmelCase    ,   return_tensors='''pt'''					).input_features


   def 					snake_case				( self    ,   _UpperCAmelCase					):
       return self.model.generate(inputs=_UpperCAmelCase					)


   def 					snake_case				( self    ,   _UpperCAmelCase					):
       return self.pre_processor.batch_decode(_UpperCAmelCase    ,   skip_special_tokens=_UpperCAmelCase					)[0]







'''simple docstring'''






import requests

snake_case_     =	"""https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey="""
def 							_lowerCamelCase(  UpperCamelCase__    : str		)		->  None:
    # fetching a list of articles in json format
    A       :       Any							=						requests.get(_NEWS_API + bbc_news_api_key		).json()
    # each article in the list is a dict
    for i, article in enumerate(bbc_news_page['''articles''']    ,       1		):
        print(F'''{i}.) {article['title']}'''		)


if __name__ == "__main__":
     fetch_bbc_news(bbc_news_api_key="""<Your BBC News API key goes here>""")
