o
    Si                     @   s&   d dl Z d dlmZ G dd dZdS )    N)CutSetc                   @   sf   e Zd ZdZ				ddededed	ejd
eddfddZde	de	fddZ
dededefddZdS )PerturbVolumea$  
    A transform on batch of cuts (``CutSet``) that perturbs the volume of the recordings
    with a given probability :attr:`p`.

    If the effect is applied, then one of the perturbation factors from the constructor's
    :attr:`factors` parameter is sampled with uniform probability.
          ?       @NFp	scale_low
scale_highrandgenpreserve_idreturnc                 C   s"   || _ || _|| _|| _|| _d S N)r   r   r   randomr
   )selfr   r   r   r	   r
    r   `/home/ubuntu/.local/lib/python3.10/site-packages/lhotse/dataset/cut_transforms/perturb_volume.py__init__   s
   
zPerturbVolume.__init__cutsc                    s,    j d u r
t   _ t fdd|D S )Nc                 3   sB    | ]} j    jkr|j  j j j d n|V  qdS ))factoraffix_idN)r   r   perturb_volume_uniformr   r   r
   ).0cutr   r   r   	<genexpr>    s    
z)PerturbVolume.__call__.<locals>.<genexpr>)r   Randomr   	from_cuts)r   r   r   r   r   __call__   s
   

zPerturbVolume.__call__lowhighc                 C   s   || j   ||   S r   )r   )r   r   r   r   r   r   r   *   s   zPerturbVolume._uniform)r   r   NF)__name__
__module____qualname____doc__floatr   r   boolr   r   r   r   r   r   r   r   r      s*    
r   )r   lhotser   r   r   r   r   r   <module>   s    