o
    㥵i8                  	   @   s  d dl Z d dlmZ d dlmZ d dlmZ G dd deZedkrd dl	Z
d dlmZ e Ze D ]"\ZZe Zed	d
 e D Zdd Zeedeeeed q3ee ededd
 e D  dZe ddeejZed e  eed Z eej!e j! dS dS )    N)AudioSignal)	BaseModel)EncodecModelc                       sF   e Zd Zddedef fddZ		dd	ejded
efddZ  Z	S )Encodec]        8@sample_rate	bandwidthc                    s>   t    |dkrt | _nt | _| j| d| _d S )Nr   D  )super__init__r   encodec_model_24khzmodelencodec_model_48khzset_target_bandwidthr   )selfr   r	   	__class__ G/home/ubuntu/.local/lib/python3.10/site-packages/dac/compare/encodec.pyr      s   


zEncodec.__init__r
   N
audio_datan_quantizersc                 C   sF   t ||}|| jj | |j}t || jj}|| d|jiS )Naudio)r   resampler   r   r   )r   r   r   r   signalreconsr   r   r   forward   s   


zEncodec.forward)r   r   )r
   N)
__name__
__module____qualname__intfloatr   torchTensorr   __classcell__r   r   r   r   r      s    r   __main__)partialc                 C      g | ]	}t | qS r   npprodsize.0pr   r   r   
<listcomp>(       r/   c                 C   s   | d|d dd S )N g    .Az<.3fz	M params.r   or.   r   r   r   <lambda>)   s    r4   
extra_reprr2   zTotal # of params: c                 C   r'   r   r(   r,   r   r   r   r/   ,   r0   i    Tr   )"r"   
audiotoolsr   audiotools.mlr   encodecr   r   r   numpyr)   	functoolsr&   r   named_modulesnmr5   r3   sum
parametersr.   fnsetattrprintlengthrandntodevicexrequires_grad_retain_gradoutshaper   r   r   r   <module>   s.    
