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

    _a		:						int=				["audio"]
    _a		:						Tuple=				["text"]
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case      ):



           '''simple docstring'''







           return self.pre_processor(snake_case		,return_tensors="""pt"""      ).input_features
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case      ):



           '''simple docstring'''







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



           '''simple docstring'''







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




class 			_lowercase :


       """simple docstring"""




       def __init__(   self							:			Any					,      __lowerCamelCase							:			int       ):


             '''simple docstring'''



             lowerCamelCase__		:				List[str]    =  n
             lowerCamelCase__		:				Union[str, Any]    =  [None] * self.n
             lowerCamelCase__		:				List[str]    =  0  # index of the first element
             lowerCamelCase__		:				Any    =  0
             lowerCamelCase__		:				Any    =  0





       def __len__(   self							:			Tuple       ):


             '''simple docstring'''



             return self.size





       def 						lowerCAmelCase     (   self							:			Optional[int]       ):


             '''simple docstring'''



             return self.size == 0





       def 						lowerCAmelCase     (   self							:			Union[str, Any]       ):


             '''simple docstring'''



             return False if self.is_empty() else self.array[self.front]





       def 						lowerCAmelCase     (   self							:			str					,      __lowerCamelCase							:			List[str]       ):


             '''simple docstring'''



             if self.size >= self.n:
                   raise Exception("QUEUE IS FULL"       )

             lowerCamelCase__		:				Optional[Any]    =  data
             lowerCamelCase__		:				Tuple    =  (self.rear + 1) % self.n
             self.size += 1
             return self





       def 						lowerCAmelCase     (   self							:			Tuple       ):


             '''simple docstring'''



             if self.size == 0:
                   raise Exception("UNDERFLOW"       )

             lowerCamelCase__		:				Any    =  self.array[self.front]
             lowerCamelCase__		:				List[Any]    =  None
             lowerCamelCase__		:				str    =  (self.front + 1) % self.n
             self.size -= 1
             return temp


