o
    Si6                     @   s:   d dl Z d dlmZmZ d dlmZmZ G dd dZdS )    N)ListOptional)CutSetRecordingSetc                   @   sh   e Zd ZdZdddddddgfdee ded	ed
ej	dedede
e ddfddZdedefddZdS )ReverbWithImpulseResponsea  
    A transform on batch of cuts (``CutSet``) that convolves each cut with an impulse
    response with some probability :attr:`p`.
    The impulse response is chosen randomly from a specified CutSet of RIRs :attr:`rir_cuts`.
    If no RIRs are specified, we will generate them using a fast random generator (https://arxiv.org/abs/2208.04101).
    If `early_only` is set to True, convolution is performed only with the first 50ms of the impulse response.
    Ng      ?TFr   rir_recordingspnormalize_outputrandgenpreserve_id
early_onlyrir_channelsreturnc                 C   s>   |d urt |ng | _|| _|| _|| _|| _|| _|| _d S )N)listr   r   r	   randomr   r   r   )selfr   r   r	   r
   r   r   r    r   ]/home/ubuntu/.local/lib/python3.10/site-packages/lhotse/dataset/cut_transforms/reverberate.py__init__   s   

z"ReverbWithImpulseResponse.__init__cutsc                    s,    j d u r
t   _ t fdd|D S )Nc                 3   sV    | ]&} j    jkr%|j jr j  jnd  j j j  jdn|V  qd S )N)rir_recordingr	   r   affix_idr   )	r   r   
reverb_rirr   choicer	   r   r   r   ).0cutr   r   r   	<genexpr>%   s    

z5ReverbWithImpulseResponse.__call__.<locals>.<genexpr>)r   Randomr   	from_cuts)r   r   r   r   r   __call__"   s
   

z"ReverbWithImpulseResponse.__call__)__name__
__module____qualname____doc__r   r   floatboolr   r   r   intr   r   r    r   r   r   r   r      s6    
	
r   )r   typingr   r   lhotser   r   r   r   r   r   r   <module>   s    