
"""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.
import torch

from ..models.speechta import SpeechTaForTextToSpeech, SpeechTaHifiGan, SpeechTaProcessor
from ..utils import is_datasets_available
from .base import PipelineTool


if is_datasets_available():
							from datasets import load_dataset




class 			A__	(     _lowerCamelCase):
		A_						:	Dict           =     'microsoft/speecht5_tts'
		A_						:	Any           =     (
		    'This is a tool that reads an English text out loud. It takes an input named `text` which should contain the '
		    'text to read (in English) and returns a waveform object containing the sound.'
		)
		A_						:	Tuple           =     'text_reader'
		A_						:	Tuple           =     SpeechTaProcessor
		A_						:	Optional[int]           =     SpeechTaForTextToSpeech
		A_						:	Tuple           =     SpeechTaHifiGan

		A_						:	Optional[int]           =     ['text']
		A_						:	int           =     ['audio']

		def 							__lowerCamelCase							(				self			):
			if self.post_processor is None:
				__lowerCAmelCase      :						Any						      =				'microsoft/speecht5_hifigan'
			super().setup()

		def 							__lowerCamelCase							(				self	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE=None			):
			__lowerCAmelCase      :						Dict						      =				self.pre_processor(text=_SCREAMING_SNAKE_CASE	,		return_tensors='pt'	,		truncation=_SCREAMING_SNAKE_CASE			)

			if speaker_embeddings is None:
				if not is_datasets_available():
					raise ImportError('Datasets needs to be installed if not passing speaker embeddings.'			)

				__lowerCAmelCase      :						Optional[Any]						      =				load_dataset('Matthijs/cmu-arctic-xvectors'	,		split='validation'			)
				__lowerCAmelCase      :						Dict						      =				torch.tensor(embeddings_dataset[73_05]['xvector']			).unsqueeze(0			)

			return {"input_ids": inputs["input_ids"], "speaker_embeddings": speaker_embeddings}

		def 							__lowerCamelCase							(				self	,		_SCREAMING_SNAKE_CASE			):
			with torch.no_grad():
				return self.model.generate_speech(**_SCREAMING_SNAKE_CASE			)







		def 							__lowerCamelCase							(				self	,		_SCREAMING_SNAKE_CASE			):
			with torch.no_grad():
				return self.post_processor(_SCREAMING_SNAKE_CASE			).cpu().detach()

"""simple docstring"""







import argparse
import datetime
def    __lowerCAmelCase    (_UpperCamelCase		):
	__lowerCAmelCase      :						Optional[Any]						      =				{
	    '0': 'Sunday',
	    '1': 'Monday',
	    '2': 'Tuesday',
	    '3': 'Wednesday',
	    '4': 'Thursday',
	    '5': 'Friday',
	    '6': 'Saturday',
	}

	__lowerCAmelCase      :						Optional[Any]						      =				{0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 0}

	# Validate
	if not 0 < len(_UpperCamelCase		) < 11:
		raise ValueError('Must be 10 characters long'		)

	# Get month
	__lowerCAmelCase      :						int						      =				int(date_input[0] + date_input[1]		)
	# Validate
	if not 0 < m < 13:
		raise ValueError('Month must be between 1 - 12'		)

	__lowerCAmelCase      :						str						      =				date_input[2]
	# Validate
	if sep_a not in ["-", "/"]:
		raise ValueError('Date separator must be \'-\' or \'/\''		)

	# Get day
	__lowerCAmelCase      :						int						      =				int(date_input[3] + date_input[4]		)
	# Validate
	if not 0 < d < 32:
		raise ValueError('Date must be between 1 - 31'		)

	# Get second separator
	__lowerCAmelCase      :						str						      =				date_input[5]
	# Validate
	if sep_a not in ["-", "/"]:
		raise ValueError('Date separator must be \'-\' or \'/\''		)

	# Get year
	__lowerCAmelCase      :						int						      =				int(date_input[6] + date_input[7] + date_input[8] + date_input[9]		)
	# Arbitrary year range
	if not 45 < y < 8500:
		raise ValueError(
		    'Year out of range. There has to be some sort of limit...right?'		)

	# Get datetime obj for validation
	__lowerCAmelCase      :						Tuple						      =				datetime.date(int(_UpperCamelCase		)	,  int(_UpperCamelCase		)	,  int(_UpperCamelCase		)		)

	# Start math
	if m <= 2:
		__lowerCAmelCase      :						int						      =				y - 1
		__lowerCAmelCase      :						Tuple						      =				m + 12
	# maths var
	__lowerCAmelCase      :						int						      =				int(str(_UpperCamelCase		)[:2]		)
	__lowerCAmelCase      :						int						      =				int(str(_UpperCamelCase		)[2:]		)
	__lowerCAmelCase      :						int						      =				int(2.6 * m - 5.39		)
	__lowerCAmelCase      :						int						      =				int(c / 4		)
	__lowerCAmelCase      :						int						      =				int(k / 4		)
	__lowerCAmelCase      :						int						      =				int(d + k		)
	__lowerCAmelCase      :						int						      =				int(t + u + v + x		)
	__lowerCAmelCase      :						int						      =				int(z - (2 * c)		)
	__lowerCAmelCase      :						int						      =				round(w % 7		)
	# End math

	# Validate math
	if f != convert_datetime_days[dt_ck.weekday()]:
		raise AssertionError('The date was evaluated incorrectly. Contact developer.'		)

	# Response
	__lowerCAmelCase      :						str						      =				F"Your date {date_input}, is a {days[str(_UpperCamelCase		)]}!"
	return response


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							lowerCamelCase__        =		argparse.ArgumentParser(
							    description=(
							        """Find out what day of the week nearly any date is or was. Enter """
							        """date as a string in the mm-dd-yyyy or mm/dd/yyyy format"""
							    )
							)
							parser.add_argument(
							    """date_input""", type=str, help="""Date as a string (mm-dd-yyyy or mm/dd/yyyy)"""
							)
							lowerCamelCase__        =		parser.parse_args()
							zeller(args.date_input)