o
    æS™iˆ  ã                   @   sr   d dl mZmZ d dlmZmZ d dlZd dlm	Z	m
Z
 d dlmZmZ eG dd„ dƒƒZe
G dd	„ d	e	ƒƒZdS )
é    )ÚasdictÚ	dataclass)ÚAnyÚDictN)ÚTorchaudioFeatureExtractorÚregister_extractor)ÚEPSILONÚSecondsc                   @   s  e Zd ZU dZeed< dZeed< dZe	ed< dZ
e	ed< d	Zeed
< d	Zeed< eZeed< dZeed< dZeed< d	Zeed< dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< deeef fd d!„Zed"eeef dd fd#d$„ƒZd%S )&ÚTorchaudioFbankConfigg        ÚditherÚpoveyÚwindow_typegš™™™™™™?Úframe_lengthg{®Gáz„?Úframe_shiftTÚremove_dc_offsetÚround_to_power_of_twoÚenergy_floorÚmin_durationg
×£p=
ï?Úpreemphasis_coefficientÚ
raw_energyg      4@Úlow_freqg      yÀÚ	high_freqéP   Únum_mel_binsFÚ
use_energyg      Y@Úvtln_lowg     @ÀÚ	vtln_highg      ð?Ú	vtln_warpÚreturnc                 C   s   t | ƒS ©N)r   )Úself© r!   úI/home/ubuntu/.local/lib/python3.10/site-packages/lhotse/features/fbank.pyÚto_dict"   ó   zTorchaudioFbankConfig.to_dictÚdatac                 C   s   t di | ¤ŽS )Nr!   )r
   )r%   r!   r!   r"   Ú	from_dict%   s   zTorchaudioFbankConfig.from_dictN) Ú__name__Ú
__module__Ú__qualname__r   ÚfloatÚ__annotations__r   Ústrr   r	   r   r   Úboolr   r   r   r   r   r   r   r   r   Úintr   r   r   r   r   r   r#   Ústaticmethodr&   r!   r!   r!   r"   r
   
   s*   
  r
   c                	   @   sn   e Zd ZdZdZeZdd„ Zdedefdd„Z	e
d	ejd
ejdedejfdd„ƒZe
dejdefdd„ƒZdS )ÚTorchaudioFbankzeLog Mel energy filter bank feature extractor based on ``torchaudio.compliance.kaldi.fbank`` function.Úfbankc                 O   s   ddl m} ||i |¤ŽS )Nr   )r1   )Útorchaudio.compliance.kaldir1   )r    ÚargsÚkwargsr1   r!   r!   r"   Ú_feature_fn1   s   zTorchaudioFbank._feature_fnÚsampling_rater   c                 C   s   | j jS r   )Úconfigr   )r    r6   r!   r!   r"   Úfeature_dim6   r$   zTorchaudioFbank.feature_dimÚ
features_aÚ
features_bÚenergy_scaling_factor_bc              
   C   s&   t  t  tt  | ¡|t  |¡  ¡¡S r   )ÚnpÚlogÚmaximumr   Úexp)r9   r:   r;   r!   r!   r"   Úmix9   s   ýÿzTorchaudioFbank.mixÚfeaturesc                 C   s   t t t | ¡¡ƒS r   )r*   r<   Úsumr?   )rA   r!   r!   r"   Úcompute_energyE   s   zTorchaudioFbank.compute_energyN)r'   r(   r)   Ú__doc__Únamer
   Úconfig_typer5   r.   r8   r/   r<   Úndarrayr*   r@   rC   r!   r!   r!   r"   r0   *   s$    ÿÿÿþr0   )Údataclassesr   r   Útypingr   r   Únumpyr<   Úlhotse.features.baser   r   Úlhotse.utilsr   r	   r
   r0   r!   r!   r!   r"   Ú<module>   s    