o
    pi                     @   sf   d dl Z d dlmZ d dlmZmZ dZeddfdeee ee eef fddZeddfd	d
Z	dS )    N)Path)ListUnion)z.wavTpathsc                 C   s   g }t | tttfrt| } n| g} | D ])}t| tr-tt	j
|}|| qt	j
|r=|t||||d7 }q|S )zReturn a list of paths to all audio files with the given extension(s) contained in the list or in its directories.
    Also traverses subdirectories by default.
    )filename_endingstraverse_subdirectoriesfollow_symlinks)
isinstancelisttuplesetstrlowerendswithSUPPORTED_EXTENSIONSr   ospathabspathappendisdirfind_audio_files)r   r   r   r   
file_pathsp	file_path r   T/home/ubuntu/.local/lib/python3.10/site-packages/torch_audiomentations/utils/file.pyfind_audio_files_in_paths	   s"   

r   c                 C   st   g }t j| |dD ].\}}}t|}|D ]}t j|}	t j|	|}
| |r1|t	|
 q|s7 |S q	|S )zReturn a list of paths to all audio files with the given extension(s) in a directory.
    Also traverses subdirectories by default.
    )followlinks)
r   walksortedr   r   joinr   r   r   r   )	root_pathr   r   r   r   rootdirs	filenamesfilename
input_pathr   r   r   r   r   (   s   	r   )
r   pathlibr   typingr   r   r   r   r   r   r   r   r   r   <module>   s    
!