o
    "i	+                     @   s   d dl Z d dlZd dlmZ ddlmZ ddlmZm	Z	 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 zd dlmZ W n eyO   d dlZY nw G dd dZG dd dZdS )    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)jsonable_encoder)remove_none_from_dict)RequestOptions)UnprocessableEntityError)HttpValidationErrorc                	   @   h   e Zd ZdefddZdddededeje d	ej	fd
dZ
dddededeje d	dfddZdS )SamplesClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   ]/var/www/html/voicebot/backend/venv/lib/python3.10/site-packages/elevenlabs/samples/client.py__init__      
zSamplesClient.__init__Nrequest_optionsvoice_id	sample_idr   returnc                C   s<  | j jjdtj| j   ddt| dt| t|dur%|dndtt	i | j 
 |dur9|di ni |durM|ddurM|dnd	d
|durX|dnd
d}d|j  krgdk rrn n	ttj| S |jdkrttt| z| }W n ty   t|j|jdw t|j|d)a  
        Removes a sample by its ID.

        Parameters:
            - voice_id: str. Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

            - sample_id: str. Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from elevenlabs.client import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.samples.delete(
            voice_id="voice_id",
            sample_id="sample_id",
        )
        DELETE/
v1/voices/	/samples/Nadditional_query_parametersadditional_headerstimeout_in_seconds<   r   max_retriesparamsheaderstimeoutretriesr&      ,    status_codebodyr   httpx_clientrequesturllibparseurljoinget_base_urlr   getr   get_headersr0   pydanticparse_obj_astypingAnyjsonr
   r   r   r   textr   r   r   r   	_response_response_jsonr   r   r   delete   sD   	

zSamplesClient.deletec                C   s,  | j jjdtj| j   ddt| dt| dt|dur&|dndtt	i | j 
 |dur:|di ni |durN|d	durN|d	nd
d|durY|dndd}d|j  kridk rjdS  |jdkryttt| z| }W n ty   t|j|jdw t|j|d)a  
        Returns the audio corresponding to a sample attached to a voice.

        Parameters:
            - voice_id: str. Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

            - sample_id: str. Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from elevenlabs.client import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.samples.get_audio(
            voice_id="voice_id",
            sample_id="sample_id",
        )
        GETr   r    r!   /audioNr"   r#   r$   r%   r   r&   r'   r,   r-   r.   r/   r   r3   r4   r5   r6   r7   r8   r   r9   r   r:   r0   r
   r;   r<   r   r?   r   r   r@   rA   r   r   r   	get_audioQ   sF   	

zSamplesClient.get_audio)__name__
__module____qualname__r   r   strr=   Optionalr	   r>   rD   rH   r   r   r   r   r      ,    
9r   c                	   @   r   )AsyncSamplesClientr   c                C   r   r   r   r   r   r   r   r      r   zAsyncSamplesClient.__init__Nr   r   r   r   r   c                   sD  | j jjdtj| j   ddt| dt| t|dur&|dndtt	i | j 
 |dur:|di ni |durN|ddurN|dnd	d
|durY|dnd
dI dH }d|j  krkdk rvn n	ttj| S |jdkrttt| z| }W n ty   t|j|jdw t|j|d)a  
        Removes a sample by its ID.

        Parameters:
            - voice_id: str. Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

            - sample_id: str. Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from elevenlabs.client import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )
        await client.samples.delete(
            voice_id="voice_id",
            sample_id="sample_id",
        )
        r   r   r    r!   Nr"   r#   r$   r%   r   r&   r'   r,   r-   r.   r/   r2   rA   r   r   r   rD      sF   	

zAsyncSamplesClient.deletec                   s4  | j jjdtj| j   ddt| dt| dt|dur'|dndtt	i | j 
 |dur;|di ni |durO|d	durO|d	nd
d|durZ|dnddI dH }d|j  krmdk rndS  |jdkr}ttt| z| }W n ty   t|j|jdw t|j|d)a  
        Returns the audio corresponding to a sample attached to a voice.

        Parameters:
            - voice_id: str. Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

            - sample_id: str. Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from elevenlabs.client import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )
        await client.samples.get_audio(
            voice_id="voice_id",
            sample_id="sample_id",
        )
        rE   r   r    r!   rF   Nr"   r#   r$   r%   r   r&   r'   r,   r-   r.   r/   rG   rA   r   r   r   rH      sH   	

zAsyncSamplesClient.get_audio)rI   rJ   rK   r   r   rL   r=   rM   r	   r>   rD   rH   r   r   r   r   rO      rN   rO   )r=   urllib.parser5   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.jsonable_encoderr   core.remove_none_from_dictr   core.request_optionsr	   !errors.unprocessable_entity_errorr
   types.http_validation_errorr   pydantic.v1v1r;   ImportErrorr   rO   r   r   r   r   <module>   s"   u