o
    óôj  ã                	   @   s8  d dl Z d dlmZ d dlmZmZmZmZmZm	Z	 d dl
mZmZmZmZmZ d dlmZmZ d dl
mZ d dlmZ d dlmZmZmZ d d	lmZmZmZ d d
lmZmZ d dl m!Z!m"Z"m#Z# e j$j%e j$j&e j$j'e j$j(e)e j$deƒe j$j*dœZ+eeeeeee	e j$j,dœZ-eeeeeeedœZ.eedœZ/dd„ Z0dS )é    N)ÚSwish)ÚLinearNoSubsamplingÚEmbedinigNoSubsamplingÚConv1dSubsampling2ÚConv2dSubsampling4ÚConv2dSubsampling6ÚConv2dSubsampling8)ÚPositionalEncodingÚRelPositionalEncodingÚWhisperPositionalEncodingÚLearnablePositionalEncodingÚNoPositionalEncoding)ÚMultiHeadedAttentionÚRelPositionMultiHeadedAttention)ÚEspnetRelPositionalEncoding)ÚLegacyLinearNoSubsampling)ÚTransformerLMÚQwen2LMÚCosyVoice3LM)ÚMaskedDiffWithXvecÚCausalMaskedDiffWithXvecÚCausalMaskedDiffWithDiT)ÚHiFTGeneratorÚCausalHiFTGenerator)ÚCosyVoiceModelÚCosyVoice2ModelÚCosyVoice3ModelÚSiLU)ÚhardtanhÚtanhÚreluÚseluÚswishÚgelu)ÚlinearZlinear_legacyÚembedZconv1d2Úconv2dZconv2d6Zconv2d8Zparaformer_dummy)r%   Zabs_posÚrel_posZrel_pos_espnetZno_posZabs_pos_whisperZembed_learnable_pe)ZselfattnZrel_selfattnc                 C   s’   t | d tƒrt | d tƒrt | d tƒrtS t | d tƒr.t | d tƒr.t | d tƒr.tS t | d tƒrEt | d t	ƒrEt | d t
ƒrEtS tdƒ‚)NÚllmÚflowÚhiftzNo valid model type found!)Ú
isinstancer   r   r   r   r   r   r   r   r   r   r   Ú	TypeError)Úconfigs© r.   úQ/var/www/html/academy/tools/voices/clone/CosyVoice/cosyvoice/utils/class_utils.pyÚget_model_typeM   s   ***r0   )1ÚtorchZ cosyvoice.transformer.activationr   Z!cosyvoice.transformer.subsamplingr   r   r   r   r   r   Zcosyvoice.transformer.embeddingr	   r
   r   r   r   Zcosyvoice.transformer.attentionr   r   r   r   Zcosyvoice.llm.llmr   r   r   Zcosyvoice.flow.flowr   r   r   Zcosyvoice.hifigan.generatorr   r   Úcosyvoice.cli.modelr   r   r   ÚnnÚHardtanhÚTanhÚReLUÚSELUÚgetattrÚGELUZCOSYVOICE_ACTIVATION_CLASSESÚIdentityZCOSYVOICE_SUBSAMPLE_CLASSESZCOSYVOICE_EMB_CLASSESZCOSYVOICE_ATTENTION_CLASSESr0   r.   r.   r.   r/   Ú<module>   sN    ú
øùþ