o
    pip                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 G dd deZ
				dd	ed
e
eB dedB dedB deeB dB deeB dB dedB fddZdS )    )Enum)Path)hf_hub_download)HfHubHTTPError)__version__c                   @   s&   e Zd ZdZdZdZdefddZdS )AssetFileNamezcalibration.safetensorszpytorch_model.binzconfig.yamlreturnc                 C   s   | j S )N)value)self r   O/home/ubuntu/.local/lib/python3.10/site-packages/pyannote/audio/utils/hf_hub.py__str__(   s   zAssetFileName.__str__N)__name__
__module____qualname__CalibrationModelPipelinestrr   r   r   r   r   r   #   s
    r   Nmodel_id
asset_file	subfolderrevision	cache_dirtokenr   c                 C   s   t |tr|dsd}zt| t |tr|jn||d|dt||d	W S  tyK   t |tr1|jn|}t	d| d|  d|  d	| d
| d|  d  w )a  Download file from Huggingface Hub

    Parameters
    ----------
    model_id : str
        Model identifier from the hf.co model hub.
    asset_file : AssetFileName
        Type of asset file to download.
    subfolder : str, optional
        Folder inside the model repo.
    revision : str, optional
        Revision when loading from the huggingface.co model hub.
    token : str or bool, optional
        Huggingface token to be used for downloading from Huggingface hub.
    cache_dir: Path or str, optional
        Path to the folder where files downloaded from Huggingface hub are stored.

    See also
    --------
    `huggingface_hub.hf_hub_download`
    hf_Nmodelpyannote)r   	repo_typer   library_namelibrary_versionr   r   z
Could not download z from zQ.
It might be because the repository is private or gated:

* visit https://hf.co/zn to accept user conditions
* visit https://hf.co/settings/tokens to create an authentication token
* load the z$ with the `token` argument:
    >>> z.from_pretrained('z', token='hf_....')
)

isinstancer   
startswithr   r   r	   r   r   nameprint)r   r   r   r   r   r   asset_file_namer   r   r   download_from_hf_hub,   sB    r&   )NNNN)enumr   pathlibr   huggingface_hubr   huggingface_hub.utilsr   pyannote.audior   r   r   boolr&   r   r   r   r   <module>   s2   

