o
    "i2                     @   s   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	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 ddlmZ ddlmZ zd dlmZ W n eya   d dlZY nw e e jdZ G dd dZ!G dd dZ"dS )    N)JSONDecodeError   )core)ApiError)AsyncClientWrapperSyncClientWrapper)jsonable_encoder)remove_none_from_dict)RequestOptions)UnprocessableEntityError)'AddPronunciationDictionaryResponseModel)*GetPronunciationDictionaryMetadataResponse)HttpValidationError.c                   @   x   e Zd ZdefddZdddddejej de	deje	 d	eje
 d
ef
ddZddde	d	eje
 d
efddZdS )PronunciationDictionaryClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   n/var/www/html/voicebot/backend/venv/lib/python3.10/site-packages/elevenlabs/pronunciation_dictionary/client.py__init__      
z&PronunciationDictionaryClient.__init__Nfiledescriptionrequest_optionsr   namer   r   returnc                C   s  | j jjdtj| j   ddt|dur|dnd|du s(|ddu r1tt	||dni tt	||dtt	|di t
t	d|itt	i | j  |dur_|d	i ni |durs|d
durs|d
ndd|dur~|dndd	}d|j  krdk rn ntt| S |jdkrttt| z| }W n ty   t|j|jdw t|j|d)a  
        Creates a new pronunciation dictionary from a lexicon .PLS file

        Parameters:
            - file: typing.Optional[core.File]. See core.File for more documentation

            - name: str. The name of the pronunciation dictionary, used for identification only.

            - description: typing.Optional[str]. A description of the pronunciation dictionary, used for identification only.

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.pronunciation_dictionary.add_from_file()
        POST/+v1/pronunciation-dictionaries/add-from-fileNadditional_query_parametersadditional_body_parametersr    r   r   additional_headerstimeout_in_seconds<   r   max_retriesparamsdatafilesheaderstimeoutretriesr+      ,    status_codebodyr   httpx_clientrequesturllibparseurljoinget_base_urlr   getr	   r   !convert_file_dict_to_httpx_tuplesget_headersr7   pydanticparse_obj_asr   jsonr   r   r   r   textr   r   r    r   r   	_response_response_jsonr   r   r   add_from_file   sR   	

z+PronunciationDictionaryClient.add_from_filer   pronunciation_dictionary_idc                C   s0  | j jjdtj| j   ddt| t|dur |dndtt	i | j 
 |dur4|di ni |durH|ddurH|dndd	|durS|d
nd	d}d|j  krbdk rln ntt| S |jdkr{ttt| z| }W n ty   t|j|jdw t|j|d)ax  
        Get metadata for a pronunciation dictionary

        Parameters:
            - pronunciation_dictionary_id: str. The id of the pronunciation dictionary

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.pronunciation_dictionary.get_metadata_for_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_pronunciation_dictionary_id_get(
            pronunciation_dictionary_id="pronunciation_dictionary_id",
        )
        GETr#   v1/pronunciation-dictionaries/Nr%   r(   r)   r*   r   r+   r-   r0   r1   r2   r+   r3   r4   r5   r6   r   r:   r;   r<   r=   r>   r?   r   r@   r	   rB   r7   rC   rD   r   rE   r   r   r   r   rF   r   rL   r   rH   rI   r   r   r   jget_metadata_for_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_pronunciation_dictionary_id_geta   sD   	

zPronunciationDictionaryClient.get_metadata_for_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_pronunciation_dictionary_id_get)__name__
__module____qualname__r   r   typingOptionalr   Filestrr
   r   rJ   r   rR   r   r   r   r   r      0    

Cr   c                   @   r   )"AsyncPronunciationDictionaryClientr   c                C   r   r   r   r   r   r   r   r      r   z+AsyncPronunciationDictionaryClient.__init__Nr   r   r    r   r   r!   c                   s  | j jjdtj| j   ddt|dur|dnd|du s)|ddu r2tt	||dni tt	||dtt	|di t
t	d|itt	i | j  |dur`|d	i ni |durt|d
durt|d
ndd|dur|dndd	I dH }d|j  krdk rn ntt| S |jdkrttt| z| }W n ty   t|j|jdw t|j|d)a  
        Creates a new pronunciation dictionary from a lexicon .PLS file

        Parameters:
            - file: typing.Optional[core.File]. See core.File for more documentation

            - name: str. The name of the pronunciation dictionary, used for identification only.

            - description: typing.Optional[str]. A description of the pronunciation dictionary, used for identification only.

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

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )
        await client.pronunciation_dictionary.add_from_file()
        r"   r#   r$   Nr%   r&   r'   r   r(   r)   r*   r   r+   r,   r3   r4   r5   r6   r9   rG   r   r   r   rJ      sT   	

z0AsyncPronunciationDictionaryClient.add_from_filerK   rL   c                   s8  | j jjdtj| j   ddt| t|dur!|dndtt	i | j 
 |dur5|di ni |durI|ddurI|dndd	|durT|d
nd	dI dH }d|j  krfdk rpn ntt| S |jdkrttt| z| }W n ty   t|j|jdw t|j|d)a  
        Get metadata for a pronunciation dictionary

        Parameters:
            - pronunciation_dictionary_id: str. The id of the pronunciation dictionary

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

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )
        await client.pronunciation_dictionary.get_metadata_for_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_pronunciation_dictionary_id_get(
            pronunciation_dictionary_id="pronunciation_dictionary_id",
        )
        rM   r#   rN   Nr%   r(   r)   r*   r   r+   rO   r3   r4   r5   r6   rP   rQ   r   r   r   rR      sF   	

zAsyncPronunciationDictionaryClient.get_metadata_for_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_pronunciation_dictionary_id_get)rS   rT   rU   r   r   rV   rW   r   rX   rY   r
   r   rJ   r   rR   r   r   r   r   r[      rZ   r[   )#rV   urllib.parser<   json.decoderr    r   core.api_errorr   core.client_wrapperr   r   core.jsonable_encoderr   core.remove_none_from_dictr	   core.request_optionsr
   !errors.unprocessable_entity_errorr   1types.add_pronunciation_dictionary_response_modelr   4types.get_pronunciation_dictionary_metadata_responser   types.http_validation_errorr   pydantic.v1v1rC   ImportErrorcastAnyOMITr   r[   r   r   r   r   <module>   s*   |