
    Pi]                         d dl mZmZ d dlmZ erd dlZ e            deedf         de	dz  de	dz  de
eef         fd	            Z e            d
ede	dz  de	dz  de
eef         fd            ZdS )    )TYPE_CHECKINGAny)documentNaudioz
np.ndarray
min_length
max_lengthreturnc                     ||;| \  }}t          |          |z  }|||k     r
ddd| ddS |||k    r
ddd| ddS ddd	S )
a  
    Validates that the audio length is within the specified min and max length (in seconds).

    Parameters:
        audio: A tuple of (sample rate in Hz, audio data as numpy array).
        min_length: Minimum length of audio in seconds. If None, no minimum length check is performed.
        max_length: Maximum length of audio in seconds. If None, no maximum length check is performed.
    Returns:
        A dict corresponding to `gr.validate()` indicating whether the audio length is valid and an optional message.
    NvalidateFz(Audio is too short. It must be at least  seconds__type__is_validmessagez&Audio is too long. It must be at most Tr   r   )len)r   r   r   sample_ratedatadurations         e/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/gradio/validators.pyis_audio_correct_lengthr   	   s     !7!Tt99{*!h&;&;&!ZjZZZ  
 !h&;&;&!XJXXX  
 #555    videoc                 ~    ddl m} ||/ ||           }|||k     r
ddd| ddS |||k    r
ddd	| ddS dd
dS )a  
    Validates that the video file length is within the specified min and max length (in seconds).

    Parameters:
        video: The path to the video file.
        min_length: Minimum length of video in seconds. If None, no minimum length check is performed.
        max_length: Maximum length of video in seconds. If None, no maximum length check is performed.
    Returns:
        A dict corresponding to `gr.validate()` indicating whether the audio length is valid and an optional message.
    r   )get_video_lengthNr   Fz(Video is too short. It must be at least r   r   z&Video is too long. It must be at most Tr   )gradio.processing_utilsr   )r   r   r   r   r   s        r   is_video_correct_lengthr   )   s     988888!7##E**!h&;&;&!ZjZZZ  
 !h&;&;&!XJXXX  
 #555r   )typingr   r   gradio_client.documentationr   numpynptupleintfloatdictstrr   r    r   r   <module>r(      s   % % % % % % % % 0 0 0 0 0 0  
6l"#6166KPSW<6	#s(^6 6 6 6> 
66!DL66;dl6	#s(^6 6 6 6 6 6r   