





"""simple docstring"""






import argparse
import hashlib  # hashlib is only used inside the Test class
import struct




class 			__lowercase     :







					'''simple docstring'''




					def __init__(  self		,     _UpperCAmelCase       ):
									__a	:  Union[str, Any]         =					data
									__a	:  Union[str, Any]         =					[0x6745_2301, 0xefcd_ab89, 0x98ba_dcfe, 0x1032_5476, 0xc3d2_e1f0]







					@staticmethod
					def 	_lowerCamelCase						(  _UpperCAmelCase		,     _UpperCAmelCase       ):
									return ((n << b) | (n >> (32 - b))) & 0xffff_ffff







					def 	_lowerCamelCase						(  self       ):
									__a	:  Optional[int]         =					b'''\x80''' + b'''\x00''' * (63 - (len(self.data       ) + 8) % 64)
									__a	:  Tuple         =					self.data + padding + struct.pack('''>Q'''		,     8 * len(self.data       )       )
									return padded_data







					def 	_lowerCamelCase						(  self       ):
									return [
									    self.padded_data[i : i + 64] for i in range(0		,     len(self.padded_data       )		,     64       )
									]







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									__a	:  List[Any]         =					list(struct.unpack('''>16L'''		,     _UpperCAmelCase       )       ) + [0] * 64
									for i in range(16		,     80       ):
													__a	:  Union[str, Any]         =					self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16])		,     1       )
									return w







					def 	_lowerCamelCase						(  self       ):
									__a	:  Optional[Any]         =					self.padding()
									__a	:  Optional[int]         =					self.split_blocks()
									for block in self.blocks:
													__a	:  Union[str, Any]         =					self.expand_block(_UpperCAmelCase       )
													__a    ,  __a    ,  __a    ,  __a    ,  __a	:  Dict         =					self.h
													for i in range(0		,     80       ):
																	if 0 <= i < 20:
																					__a	:  int         =					(b & c) | ((~b) & d)
																					__a	:  Any         =					0x5a82_7999
																	elif 20 <= i < 40:
																					__a	:  Optional[Any]         =					b ^ c ^ d
																					__a	:  int         =					0x6ed9_eba1
																	elif 40 <= i < 60:
																					__a	:  Any         =					(b & c) | (b & d) | (c & d)
																					__a	:  List[Any]         =					0x8f1b_bcdc
																	elif 60 <= i < 80:
																					__a	:  Dict         =					b ^ c ^ d
																					__a	:  Optional[Any]         =					0xca62_c1d6
																	__a    ,  __a    ,  __a    ,  __a    ,  __a	:  Any         =					(
																	    self.rotate(_UpperCAmelCase		,     5       ) + f + e + k + expanded_block[i] & 0xffff_ffff,
																	    a,
																	    self.rotate(_UpperCAmelCase		,     30       ),
																	    c,
																	    d,
																	)
													__a	:  Tuple         =					(
													    self.h[0] + a & 0xffff_ffff,
													    self.h[1] + b & 0xffff_ffff,
													    self.h[2] + c & 0xffff_ffff,
													    self.h[3] + d & 0xffff_ffff,
													    self.h[4] + e & 0xffff_ffff,
													)
									return ("{:08x}" * 5).format(*self.h       )






def       __A (     )						->						int:
				__a	:  Optional[int]         =					b'''Test String'''
				assert SHAaHash(a_).final_hash() == hashlib.shaa(a_).hexdigest()  # noqa: S324

def       __A (     )						->						Union[str, Any]:
				__a	:  Dict         =					argparse.ArgumentParser(description='''Process some strings or files''')
				parser.add_argument(
				    '''--string'''				,    dest='''input_string'''				,    default='''Hello World!! Welcome to Cryptography'''				,    help='''Hash the string'''				,    )
				parser.add_argument('''--file'''				,    dest='''input_file'''				,    help='''Hash contents of a file''')
				__a	:  Optional[Any]         =					parser.parse_args()
				__a	:  Any         =					args.input_string
				# In any case hash input should be a bytestring
				if args.input_file:
								with open(args.input_file				,    '''rb''') as f:
												__a	:  List[str]         =					f.read()
				else:
								__a	:  Any         =					bytes(a_				,    '''utf-8''')
				print(SHAaHash(a_).final_hash())


if __name__ == "__main__":
		main()
		import doctest

		doctest.testmod()






"""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 			__lowercase     (     _UpperCamelCase							):







					'''simple docstring'''




					__lowerCAmelCase					=					'''openai/whisper-base'''
					__lowerCAmelCase					=					(
					    '''This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the '''
					    '''transcribed text.'''
					)
					__lowerCAmelCase					=					'''transcriber'''
					__lowerCAmelCase					=					WhisperProcessor
					__lowerCAmelCase					=					WhisperForConditionalGeneration

					__lowerCAmelCase					=					['''audio''']
					__lowerCAmelCase					=					['''text''']







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									return self.pre_processor(_UpperCAmelCase		,     return_tensors='''pt'''       ).input_features







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									return self.model.generate(inputs=_UpperCAmelCase       )







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									return self.pre_processor.batch_decode(_UpperCAmelCase		,     skip_special_tokens=_UpperCAmelCase       )[0]