"""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    a_   (  __UpperCamelCase      ):
					UpperCamelCase_			:						Tuple      =     "openai/whisper-base"
					UpperCamelCase_			:						List[Any]      =     (
					    "This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the "
					    "transcribed text."
					)
					UpperCamelCase_			:						List[Any]      =     "transcriber"
					UpperCamelCase_			:						Tuple      =     WhisperProcessor
					UpperCamelCase_			:						Dict      =     WhisperForConditionalGeneration

					UpperCamelCase_			:						Optional[int]      =     ["audio"]
					UpperCamelCase_			:						Union[str, Any]      =     ["text"]




					def     _SCREAMING_SNAKE_CASE    (						self    :  Union[str, Any]	,    snake_case__    :  Tuple  ):
							return self.pre_processor(snake_case__	,    return_tensors="""pt"""  ).input_features




					def     _SCREAMING_SNAKE_CASE    (						self    :  List[Any]	,    snake_case__    :  Tuple  ):
							return self.model.generate(inputs=snake_case__  )




					def     _SCREAMING_SNAKE_CASE    (						self    :  Dict	,    snake_case__    :  Dict  ):
							return self.pre_processor.batch_decode(snake_case__	,    skip_special_tokens=snake_case__  )[0]





"""simple docstring"""




import numpy as np
from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey







def 				_UpperCAmelCase		(							lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__  ):





		"""simple docstring"""




		if (ksize % 2) == 0:
				lowerCAmelCase__   = ksize + 1
		lowerCAmelCase__   = np.zeros((ksize, ksize)      ,	dtype=np.floataa  )

		# each value
		for y in range(lowerCamelCase__  ):
				for x in range(lowerCamelCase__  ):
						# distance from center
						lowerCAmelCase__   = x - ksize // 2
						lowerCAmelCase__   = y - ksize // 2

						# degree to radiant
						lowerCAmelCase__   = theta / 180 * np.pi
						lowerCAmelCase__   = np.cos(_theta  )
						lowerCAmelCase__   = np.sin(_theta  )

						# get kernel x
						lowerCAmelCase__   = cos_theta * px + sin_theta * py

						# get kernel y
						lowerCAmelCase__   = -sin_theta * px + cos_theta * py

						# fill kernel
						lowerCAmelCase__   = np.exp(
						    -(_x**2 + gamma**2 * _y**2) / (2 * sigma**2)  ) * np.cos(2 * np.pi * _x / lambd + psi  )

		return gabor


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			# read original image
			__lowerCAmelCase     :				Tuple    				=    imread("../image_data/lena.jpg")
			# turn image in gray scale value
			__lowerCAmelCase     :				List[str]    				=    cvtColor(img, COLOR_BGR2GRAY)

			# Apply multiple Kernel to detect edges
			__lowerCAmelCase     :				Union[str, Any]    				=    np.zeros(gray.shape[:2])
			for theta in [0, 30, 60, 90, 1_20, 1_50]:
						__lowerCAmelCase     :				Union[str, Any]    				=    gabor_filter_kernel(10, 8, theta, 10, 0, 0)
						out += filteraD(gray, CV_8UC3, kernel_aa)
			__lowerCAmelCase     :				Optional[int]    				=    out / out.max() * 2_55
			__lowerCAmelCase     :				Tuple    				=    out.astype(np.uinta)

			imshow("Original", gray)
			imshow("Gabor filter with 20x20 mask and 6 directions", out)

			waitKey(0)




