



import re

from ..utils import cached_file


# docstyle-ignore
_lowercase  				=    '''
Human: <<task>>

Assistant: '''


_lowercase  				=    '''huggingface-tools/default-prompts'''
_lowercase  				=    {'''chat''': '''chat_prompt_template.txt''', '''run''': '''run_prompt_template.txt'''}






def   _A					(UpperCamelCase		:   int   ,      UpperCamelCase		:   int   ,      UpperCamelCase		:   Tuple="run"			)	->List[Any]:



			'''simple docstring'''







			if prompt_or_repo_id is None:
						lowerCamelCase__			:   Optional[Any]										=		DEFAULT_PROMPTS_REPO

			# prompt is considered a repo ID when it does not contain any kind of space
			if re.search("""\\s"""   ,      lowerCAmelCase_			) is not None:
						return prompt_or_repo_id

			lowerCamelCase__			:   Union[str, Any]										=		cached_file(
			    lowerCAmelCase_   ,      PROMPT_FILES[mode]   ,      repo_type="""dataset"""   ,      user_agent={"""agent""": agent_name}			)
			with open(lowerCAmelCase_   ,      """r"""   ,      encoding="""utf-8"""			) as f:
						return f.read()








"""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]





