
    ~VjiC                         d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlZd dl	m
Z
  ej        e          Zd Zd Zdd	Z	 	 ddddededeeef         dedef
dZdS )    N)PathLike)Path)Uniondownload_url_to_filec                     t          t          j                                                  dz  t          |           z  }|j                            dd           |S )N
torchaudioT)parentsexist_ok)r   torchhubget_dirparentmkdir)keypaths     S/root/voice-cloning/.venv/lib/python3.11/site-packages/torchaudio/utils/download.py_get_local_pathr      sM    	!!##$$|3d3ii?DKdT222K    c                 4    d|  }t          |||           d S )Nz(https://download.pytorch.org/torchaudio/progressr   )r   r   r   urls       r   	_downloadr      s*    
:S
:
:CdX666666r     c                 &   t          j                    }t          | d          5 }|                    |          }|r,|                    |           |                    |          }|,d d d            n# 1 swxY w Y   |                                S )Nrb)hashlibsha256openreadupdate	hexdigest)r   hash
chunk_sizemfiledatas         r   	_get_hashr)      s    A	dD		 )Tyy$$ 	)HHTNNN99Z((D  	)) ) ) ) ) ) ) ) ) ) ) ) ) ) )
 ;;==s   AA44A8;A8 Tr   r   r$   r   r   returnc          	         |pt          |           }|                                rt                              d|           n.t                              d| |           t	          | ||           |rct                              d           t          ||          }||k    rt          d| d| d| d          t                              d	           t          |          S )
a4  Download and store torchaudio assets to local file system.

    If a file exists at the download path, then that path is returned with or without
    hash validation.

    Args:
        key (str): The asset identifier.
        hash (str, optional):
            The value of SHA256 hash of the asset. If provided, it is used to verify
            the downloaded / cached object. If not provided, then no hash validation
            is performed. This means if a file exists at the download path, then the path
            is returned as-is without verifying the identity of the file.
        path (path-like object, optional):
            By default, the downloaded asset is saved in a directory under
            :py:func:`torch.hub.get_dir` and intermediate directories based on the given `key`
            are created.
            This argument can be used to overwrite the target location.
            When this argument is provided, all the intermediate directories have to be
            created beforehand.
        progress (bool): Whether to show progress bar for downloading. Default: ``True``.

    Note:
        Currently the valid key values are the route on ``download.pytorch.org/torchaudio``,
        but this is an implementation detail.

    Returns:
        str: The path to the asset on the local file system.
    z2The local file (%s) exists. Skipping the download.zDownloading %s to %sr   zVerifying the hash value.z'The hash value of the downloaded file (z), 'z+' does not match the provided hash value, 'z'.zHash validated.)r   exists_LGinfor   r)   
ValueErrorstr)r   r$   r   r   digests        r   _download_assetr3   "   s    F '?3''D{{}} 0EtLLLL'd333#th//// 
$,---4&&T>>6$ 6 6F 6 6-16 6 6  
 	"###t99r   )r   )r*   r*   )r   loggingosr   pathlibr   typingr   r   torchaudio._internalr   	getLogger__name__r.   r   r   r)   r1   boolr3    r   r   <module>r=      s                        5 5 5 5 5 5g!!  7 7 7
    !#7
 7 7 7	7
7 X
7
 7 	7 7 7 7 7 7r   