
    b6i>/                        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 j6                  e j8                  d      Z G d d      Z G d d      Zy)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)'convert_and_respect_annotation_metadata)construct_type)UnprocessableEntityError)HttpValidationError))PronunciationDictionaryRulesResponseModel   )PronunciationDictionaryRule.c            
           e Zd ZdefdZdddedej                  e   dej                  e
   dee   fd	Zddded
ej                  e   dej                  e
   dee   fdZy)RawRulesClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     /root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/pronunciation_dictionaries/rules/raw_client.py__init__zRawRulesClient.__init__   
    -    Nrequest_optionspronunciation_dictionary_idrulesr!   returnc                @   | j                   j                  j                  dt        |       dddt	        |t
        j                  t           d      iddi|t        	      }	 d
|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rUt        t!        |j"                        t        j                  t$        t        t$        |j                                           |j                         }t)        |j                  t!        |j"                        |      # t&        $ r6 t)        |j                  t!        |j"                        |j*                        w xY w)aB  
        Add rules to the pronunciation dictionary. If a rule with the same string_to_replace already exists, it will be replaced.

        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  r3   bodystatus_coder3   r>   )r   httpx_clientrequestr
   r   typingSequencer   OMITr@   castr   r   r2   r	   r   dictr3   r   r   r   textr   r"   r#   r!   	_response_data_response_jsons          r   addzRawRulesClient.add   sz   8 ((55==,-=>Y-Z,[[ef@!foo>Y.Zfm  2 , > 
		ti++1c1="G ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   #AE ?A4E ?Frule_stringsc                   | j                   j                  j                  dt        |       ddd|iddi|t              }	 d|j
                  cxk  rd	k  rGn nDt        j                  t        t        t        |j                         
            }t        ||      S |j
                  dk(  rUt        t        |j                        t        j                  t        t        t        |j                         
                  |j                         }t#        |j
                  t        |j                        |      # t         $ r6 t#        |j
                  t        |j                        |j$                        w xY w)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(   rN   r.   r/   r0   r5   r6   r7   r9   r<   r=   r?   )r   rA   rB   r
   rE   r@   rC   rF   r   r   r2   r	   r   rG   r3   r   r   r   rH   r   r"   rN   r!   rJ   rK   rL   s          r   removezRawRulesClient.remove^   sb   4 ((55==,-=>Y-Z,[[hi  2 , > 
		ti++1c1="G ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AD= A4D= =?E<)__name__
__module____qualname__r   r   strrC   rD   r   Optionalr   r	   r   rM   rR    r   r   r   r      s    .*; . <@Bp%(Bp :;	Bp
  8Bp 
?	@BpR <@>p%(>p ooc*	>p
  8>p 
?	@>pr   r   c            
           e Zd ZdefdZdddedej                  e   dej                  e
   dee   fd	Zddded
ej                  e   dej                  e
   dee   fdZy)AsyncRawRulesClientr   c                    || _         y r   r   r   s     r   r   zAsyncRawRulesClient.__init__   r   r   Nr    r"   r#   r!   r$   c                ^  K   | j                   j                  j                  dt        |       dddt	        |t
        j                  t           d      iddi|t        	       d
{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rUt        t!        |j"                        t        j                  t$        t        t$        |j                                           |j                         }t)        |j                  t!        |j"                        |      7 # t&        $ r6 t)        |j                  t!        |j"                        |j*                        w xY ww)aG  
        Add rules to the pronunciation dictionary. If a rule with the same string_to_replace already exists, it will be replaced.

        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/   r0   Nr5   r6   r7   r9   r<   r=   r?   )r   rA   rB   r
   r   rC   rD   r   rE   r@   rF   r   r   r2   r   r   rG   r3   r   r   r   rH   rI   s          r   rM   zAsyncRawRulesClient.add   s    8 ..;;CC,-=>Y-Z,[[ef@!foo>Y.Zfm  2 , D 
 
		ti++1c1="G ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooM
H  	ty'<'<d9K\K\F]dmdrdrss	ts8   A%F-'E((F--AE+ F-	A4E+ =,F-+?F**F-rN   c                  K   | j                   j                  j                  dt        |       ddd|iddi|t               d{   }	 d	|j
                  cxk  rd
k  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j
                  dk(  rUt        t        |j                        t        j                  t        t        t        |j                                           |j                         }t#        |j
                  t        |j                        |      7 # t         $ r6 t#        |j
                  t        |j                        |j$                        w xY ww)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&   rP   r(   rN   r.   r/   r0   Nr5   r6   r7   r9   r<   r=   r?   )r   rA   rB   r
   rE   r@   rC   rF   r   r   r2   r   r   rG   r3   r   r   r   rH   rQ   s          r   rR   zAsyncRawRulesClient.remove   sr    4 ..;;CC,-=>Y-Z,[[hi  2 , D 
 
		ti++1c1="G ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooI
D  	ty'<'<d9K\K\F]dmdrdrss	ts8   AFEFAE
 'F(A4E
 ,F
?F		F)rS   rT   rU   r   r   rV   rC   rD   r   rW   r   r   r   rM   rR   rX   r   r   rZ   rZ      s    .*< . <@Bp%(Bp :;	Bp
  8Bp 
D	EBpR <@>p%(>p ooc*	>p
  8>p 
D	E>pr   rZ   ) rC   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   rF   AnyrE   r   rZ   rX   r   r   <module>rk      sc     ( & H A 5 2 I 7 I > l L v{{6::s#Fp FpRFp Fpr   