



'''simple docstring'''
from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor
from .base import PipelineTool



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

		_SCREAMING_SNAKE_CASE    :			List[str]  					=	["audio"]
		_SCREAMING_SNAKE_CASE    :			Tuple  					=	["text"]





		def 							__A				(   self       ,				__UpperCAmelCase )				->   int:

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





		def 							__A				(   self       ,				__UpperCAmelCase )				->   Dict:

					'''simple docstring'''
					return self.model.generate(inputs=UpperCAmelCase__ )





		def 							__A				(   self       ,				__UpperCAmelCase )				->   int:

					'''simple docstring'''
					return self.pre_processor.batch_decode(UpperCAmelCase__       ,				skip_special_tokens=UpperCAmelCase__ )[0]







"""simple docstring"""





import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin




class 					_lowerCAmelCase  (	unittest.TestCase     ,lowercase   ):







 """simple docstring"""







 def 					_lowercase (			self							:			List[Any]	):
    __lowercase								=						load_tool("text-classification"	)
    self.tool.setup()
    __lowercase								=						load_tool("text-classification",					remote=UpperCAmelCase__	)


 def 					_lowercase (			self							:			str	):
    __lowercase								=						self.tool("That's quite cool",					["positive", "negative"]	)
    self.assertEqual(UpperCAmelCase__,					"positive"	)


 def 					_lowercase (			self							:			str	):
    __lowercase								=						self.remote_tool("That's quite cool",					["positive", "negative"]	)
    self.assertEqual(UpperCAmelCase__,					"positive"	)


 def 					_lowercase (			self							:			List[str]	):
    __lowercase								=						self.tool(text="That's quite cool",					labels=["positive", "negative"]	)
    self.assertEqual(UpperCAmelCase__,					"positive"	)



 def 					_lowercase (			self							:			Tuple	):
    __lowercase								=						self.remote_tool(text="That's quite cool",					labels=["positive", "negative"]	)
    self.assertEqual(UpperCAmelCase__,					"positive"	)




