o
    Si|                     @   s6   d dl Z d dlmZmZ d dlmZ G dd dZdS )    N)SequenceUnion)CutSetc                   @   sT   e Zd ZdZ		ddeeee f dedejde	ddf
d	d
Z
dedefddZdS )PerturbSpeeda#  
    A transform on batch of cuts (``CutSet``) that perturbs the speed 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factorsprandgenpreserve_idreturnc                 C   s,   t |tr|n|g| _|| _|| _|| _d S )N)
isinstancer   r   r   randomr	   )selfr   r   r   r	    r   _/home/ubuntu/.local/lib/python3.10/site-packages/lhotse/dataset/cut_transforms/perturb_speed.py__init__   s   
zPerturbSpeed.__init__cutsc                    s,    j d u r
t   _ t fdd|D S )Nc                 3   s@    | ]} j    jkr|j j  j j d n|V  qdS ))factoraffix_idN)r   r   perturb_speedchoicer   r	   ).0cutr   r   r   	<genexpr>   s    
z(PerturbSpeed.__call__.<locals>.<genexpr>)r   Randomr   	from_cuts)r   r   r   r   r   __call__   s
   

zPerturbSpeed.__call__)NF)__name__
__module____qualname____doc__r   floatr   r   r   boolr   r   r   r   r   r   r   r      s     
r   )r   typingr   r   lhotser   r   r   r   r   r   <module>   s    