o
    lWi.                     @   s   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	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 ddlmZ e e jdZG dd dZG dd dZdS )    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)'convert_and_respect_annotation_metadata)construct_type)UnprocessableEntityError)HttpValidationError))PronunciationDictionaryRulesResponseModel   )PronunciationDictionaryRule.c                
   @   z   e Zd ZdefddZdddedeje dej	e
 d	ee fd
dZdddedeje dej	e
 d	ee fddZdS )RawRulesClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   z/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/pronunciation_dictionaries/rules/raw_client.py__init__      
zRawRulesClient.__init__Nrequest_optionspronunciation_dictionary_idrulesr    returnc             	   C   s   | j jjdt| dddt|tjt ddiddi|td	}z>d
|j	  kr+dk r@n nt
ttt| d}t||dW S |j	dkrXtt|jt
ttt| dd| }W n typ   t|j	t|j|jdw t|j	t|j|d)a  
        Add rules to the pronunciation dictionary

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

        rules : typing.Sequence[PronunciationDictionaryRule]
            List of pronunciation rules. Rule can be either:
                an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', }
                or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' }

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[PronunciationDictionaryRulesResponseModel]
            Successful Response
        v1/pronunciation-dictionaries/
/add-rulesPOSTr"   writeobject_
annotation	directioncontent-typeapplication/jsonmethodjsonheadersr    omit   ,  type_r)   responsedata  r1   bodystatus_coder1   r<   )r   httpx_clientrequestr	   r   typingSequencer   OMITr>   castr   r   r0   r   r   dictr1   r   r   r   textr   r!   r"   r    	_response_data_response_jsonr   r   r   add   sL   

zRawRulesClient.addrule_stringsc             	   C   s   | j jjdt| ddd|iddi|td}z>d|j  kr#d	k r8n nttt	t|
 d
}t||dW S |jdkrPtt|jttt	t|
 d
d|
 }W n tyh   t|jt|j|jdw t|jt|j|d)a"  
        Remove rules from the pronunciation dictionary

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

        rule_strings : typing.Sequence[str]
            List of strings to remove from the pronunciation dictionary.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[PronunciationDictionaryRulesResponseModel]
            Successful Response
        r$   /remove-rulesr&   rL   r,   r-   r.   r3   r4   r5   r7   r:   r;   r=   )r   r?   r@   r	   rC   r>   rA   rD   r   r   r0   r   r   rE   r1   r   r   r   rF   r   r!   rL   r    rH   rI   rJ   r   r   r   remove^   sH   

zRawRulesClient.remove)__name__
__module____qualname__r   r   strrA   rB   r   Optionalr
   r   r   rK   rO   r   r   r   r   r      ,    
Ir   c                
   @   r   )AsyncRawRulesClientr   c                C   r   r   r   r   r   r   r   r      r   zAsyncRawRulesClient.__init__Nr   r!   r"   r    r#   c             	      s   | j jjdt| dddt|tjt ddiddi|td	I d
H }z>d|j	  kr/dk rDn nt
ttt| d}t||dW S |j	dkr\tt|jt
ttt| dd| }W n tyt   t|j	t|j|jdw t|j	t|j|d)a  
        Add rules to the pronunciation dictionary

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

        rules : typing.Sequence[PronunciationDictionaryRule]
            List of pronunciation rules. Rule can be either:
                an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', }
                or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' }

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[PronunciationDictionaryRulesResponseModel]
            Successful Response
        r$   r%   r&   r"   r'   r(   r,   r-   r.   Nr3   r4   r5   r7   r:   r;   r=   )r   r?   r@   r	   r   rA   rB   r   rC   r>   rD   r   r   r0   r   r   rE   r1   r   r   r   rF   rG   r   r   r   rK      sN   

zAsyncRawRulesClient.addrL   c             	      s   | j jjdt| ddd|iddi|tdI dH }z>d	|j  kr'd
k r<n nttt	t|
 d}t||dW S |jdkrTtt|jttt	t|
 dd|
 }W n tyl   t|jt|j|jdw t|jt|j|d)a'  
        Remove rules from the pronunciation dictionary

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

        rule_strings : typing.Sequence[str]
            List of strings to remove from the pronunciation dictionary.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[PronunciationDictionaryRulesResponseModel]
            Successful Response
        r$   rM   r&   rL   r,   r-   r.   Nr3   r4   r5   r7   r:   r;   r=   )r   r?   r@   r	   rC   r>   rA   rD   r   r   r0   r   r   rE   r1   r   r   r   rF   rN   r   r   r   rO      sJ   

zAsyncRawRulesClient.remove)rP   rQ   rR   r   r   rS   rA   rB   r   rT   r
   r   r   rK   rO   r   r   r   r   rV      rU   rV   ) rA   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r   core.jsonable_encoderr	   core.request_optionsr
   core.serializationr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr   types.http_validation_errorr   3types.pronunciation_dictionary_rules_response_modelr   #types.pronunciation_dictionary_ruler   rD   AnyrC   r   rV   r   r   r   r   <module>   s"    
