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



class     _A   (    __UpperCamelCase							):
  SCREAMING_SNAKE_CASE_	:	Dict						="openai/whisper-base"
  SCREAMING_SNAKE_CASE_	:	Optional[int]						=(
      "This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the "
      "transcribed text."
  )
  SCREAMING_SNAKE_CASE_	:	Optional[int]						="transcriber"
  SCREAMING_SNAKE_CASE_	:	str						=WhisperProcessor
  SCREAMING_SNAKE_CASE_	:	Tuple						=WhisperForConditionalGeneration

  SCREAMING_SNAKE_CASE_	:	str						=["audio"]
  SCREAMING_SNAKE_CASE_	:	Tuple						=["text"]






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_	)		->      Union[str, Any]:





       '''simple docstring'''





       return self.pre_processor(__a   ,				return_tensors='''pt'''	).input_features






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_	)		->      List[str]:





       '''simple docstring'''





       return self.model.generate(inputs=__a	)






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_	)		->      Union[str, Any]:





       '''simple docstring'''





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




from datetime import datetime

import matplotlib.pyplot as plt
import torch







def  __UpperCamelCase    (						A							):
     for param in module.parameters():
          UpperCamelCase__										=      False







def  __UpperCamelCase    (						):
     UpperCamelCase__										=      '''cuda''' if torch.cuda.is_available() else '''cpu'''
     if torch.backends.mps.is_available() and torch.backends.mps.is_built():
          UpperCamelCase__										=      '''mps'''
     if device == "mps":
          print(
              '''WARNING: MPS currently doesn\'t seem to work, and messes up backpropagation without any visible torch'''
              ''' errors. I recommend using CUDA on a colab notebook or CPU instead if you\'re facing inexplicable issues'''
              ''' with generations.'''							)
     return device







def  __UpperCamelCase    (						A							):
     UpperCamelCase__										=      plt.imshow(A							)
     fig.axes.get_xaxis().set_visible(A							)
     fig.axes.get_yaxis().set_visible(A							)
     plt.show()







def  __UpperCamelCase    (						):
     UpperCamelCase__										=      datetime.now()
     UpperCamelCase__										=      current_time.strftime('''%H:%M:%S'''							)
     return timestamp



