o
    SiB                  
   @   s<  d dl mZ d dlZd dlmZ d dlmZ ejddejdejdd	d
dej	dd	dddede
fddZejddejdejdd	d
dejdejdd	d
dej	dd	dddedede
fddZejddejdejdd	d
dejdejdd	d
dejde ddededefddZdS )    )PathN)cli)Pathlikevalidate)namemanifestTF)existsdir_okay)typez--read-data/--dont-read-dataz|Should the audio/features data be read from disk to perform additional checks (could be extremely slow for large manifests).)defaulthelp	read_datac              
   C   sb   ddl m}m} || }z	|||d W dS  ty0 } ztd|  W Y d}~dS d}~ww )z Validate a Lhotse manifest file.r   )load_manifestr   )r   Validation failed: N   )lhotser   r   AssertionErrorclickecho)r   r   r   r   datae r   M/home/ubuntu/.local/lib/python3.10/site-packages/lhotse/bin/modes/validate.py	validate_	   s   
r   zvalidate-pair
recordingssupervisionsc              
   C   sl   ddl m}m} || }||}z
||||d W dS  ty5 } ztd|  W Y d}~dS d}~ww )z
    Validate a pair of Lhotse RECORDINGS and SUPERVISIONS manifest files.
    Checks whether the two manifests are consistent with each other.
    r   )r   $validate_recordings_and_supervisions)r   r   r   r   Nr   )r   r   r   r   r   r   )r   r   r   r   r   recssupsr   r   r   r   r      s   fix
output_dirc                 C   s   ddl m}m}m} t|}t| } t|}|jddd || }||}|||d\}}||| j  |||j  dS )a$  
    Fix a pair of Lhotse RECORDINGS and SUPERVISIONS manifests.
    It removes supervisions without corresponding recordings and vice versa,
    trims the supervisions that exceed the recording, etc.
    Stores the output files in OUTPUT_DIR under the same names as the input
    files.
    r   )RecordingSetSupervisionSetfix_manifestsT)parentsexist_ok)r   r   N)	r   r!   r"   r#   r   mkdir	from_fileto_filer   )r   r   r    r!   r"   r#   r   r   r   r   r   fix_8   s   

r)   )pathlibr   r   lhotse.bin.modes.cli_baser   lhotse.utilsr   commandargumentoptionboolr   r)   r   r   r   r   <module>   s4    


"