CoolFace
Apppublic

mohan32189/Sanskrit-TTS

sourceHugging Facegpl-3.0updated 4y agoView on Hugging Face
0likes
utils.cpython-37.pyc32 linesDownload Raw Back to __pycache__
1B

2�)c��@sbddlZddlmZddlmZmZddlmZddlZGdd�d�Z	dd�Z3d	d4�Zdd�ZdS)
�N)�loads)�load�FloatTensor)�float32c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d5�Zdd�Zd
d�Z	dd�Z6dd�ZdS)�HParamscKs8x2|��D]&\}}t|�tkr(tf|�}|||<q7WdS)N)�items�type�dictr)�self�kwargs�k�v�r�!e:\Projects\Sanskrit-TTS\utils.py�__init__	s8zHParams.__init__cCs9|j��S)N)�__dict__�keys)r10rrrrszHParams.keyscCs11|j��S)N)rr)r12rrrrsz
HParams.itemscCs13|j��S)N)r�values)r14rrrrszHParams.valuescCs15t|j�S)N)�lenr)r16rrr�__len__szHParams.__len__cCs17t||�S)N)�getattr)r18�keyrrr�__getitem__szHParams.__getitem__cCst|||�S)N)�setattr)r19r�valuerrr�__setitem__szHParams.__setitem__cCs20||jkS)N)r)r21rrrr�__contains__!szHParams.__contains__cCs22|j��S)N)r�__repr__)r23rrrr$szHParams.__repr__N)�__name__�24__module__�__qualname__rrrrrrrrrrrrrrsrc	Cs�t|dd�}|d}|d}t|d�r2|j��}n|��}i}xH|��D]<\}}y||||<WqHt�d|�|||<YqHXqHWt|d�r�|j�|�n25|�|�t�d�||��dS)N�cpu)�map_location�	iteration�model�modulez%s is not in the checkpointz%Loaded checkpoint '{}' (iteration {}))	r�hasattrr%�26state_dictr�logging�info�load_state_dict�format)	Zcheckpoint_pathr$Zcheckpoint_dictr#Zsaved_state_dictr'Znew_state_dictrr
rrr�load_checkpoint(s&27282930r,c	Cs4t|d��}|��}WdQRXt|�}tf|�}|S)N�r)�open�readrr)Zconfig_path�f�data�configZhparamsrrr�get_hparams_from_file@s3132r3cCs"tj||dd�\}}t|�t��S)NT)�sr�mono)�librosarr�astyper)�	full_pathZtarget_sampling_rateZaudioZ
sampling_raterrr�load_audio_to_torchIsr9)
r(�jsonr�torchrr�numpyrr6rr,r3r9rrrr�<module>s