
    b6iN                        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)construct_type)UnprocessableEntityError)HttpValidationError)SimilarVoicesForSpeakerResponse)SpeakerCreatedResponse)SpeakerUpdatedResponse.c                   H   e Zd ZdefdZeeeeeedddededej                  e   dej                  e   d	ej                  e	   d
ej                  e	   dej                  e	   dej                  ej                  e      dej                  e   dee   fdZeeeeedddedej                  e   dej                  e   d	ej                  e	   d
ej                  e	   dej                  e	   dej                  e   dee   fdZdddededej                  e   dee   fdZy)RawSpeakerClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     y/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/dubbing/resource/speaker/raw_client.py__init__zRawSpeakerClient.__init__   
    -    Nspeaker_namevoice_idvoice_stabilityvoice_similarityvoice_style	languagesrequest_options
dubbing_id
speaker_idr    r!   r"   r#   r$   r%   r&   returnc                   | j                   j                  j                  dt        |       dt        |       d||||||d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  
        Amend the metadata associated with a speaker, such as their voice. Both voice cloning and using voices from the ElevenLabs library are supported.

        Parameters
        ----------
        dubbing_id : str
            ID of the dubbing project.

        speaker_id : str
            ID of the speaker.

        speaker_name : typing.Optional[str]
            Name to attribute to this speaker.

        voice_id : typing.Optional[str]
            Either the identifier of a voice from the ElevenLabs voice library, or one of ['track-clone', 'clip-clone'].

        voice_stability : typing.Optional[float]
            For models that support it, the voice similarity value to use. This will default to 0.65, with a valid range of [0.0, 1.0].

        voice_similarity : typing.Optional[float]
            For models that support it, the voice similarity value to use. This will default to 1.0, with a valid range of [0.0, 1.0].

        voice_style : typing.Optional[float]
            For models that support it, the voice style value to use. This will default to 1.0, with a valid range of [0.0, 1.0].

        languages : typing.Optional[typing.Sequence[str]]
            Languages to apply these changes to. If empty, will apply to all languages.

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

        Returns
        -------
        HttpResponse[SpeakerUpdatedResponse]
            Successful Response
        v1/dubbing/resource/	/speaker/PATCHr    r!   r"   r#   r$   r%   content-typeapplication/jsonmethodjsonheadersr&   omit   ,  type_object_responsedata  r4   bodystatus_coder4   r@   )r   httpx_clientrequestr
   OMITrB   typingcastr   r   r3   r	   r   dictr4   r   r   r   textr   r'   r(   r    r!   r"   r#   r$   r%   r&   	_response_data_response_jsons                r   updatezRawSpeakerClient.update   sz   d ((55=="#3J#?"@	JZ[eJfIgh ,$#2$4*&  2 , > 
	"	ti++1c1*"4 ) 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r    r!   r"   r#   r$   r&   c                   | j                   j                  j                  dt        |       dd|||||d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)af  
        Parameters
        ----------
        dubbing_id : str
            ID of the dubbing project.

        speaker_name : typing.Optional[str]
            Name to attribute to this speaker.

        voice_id : typing.Optional[str]
            Either the identifier of a voice from the ElevenLabs voice library, or one of ['track-clone', 'clip-clone'].

        voice_stability : typing.Optional[float]
            For models that support it, the voice similarity value to use. This will default to 0.65, with a valid range of [0.0, 1.0].

        voice_similarity : typing.Optional[float]
            For models that support it, the voice similarity value to use. This will default to 1.0, with a valid range of [0.0, 1.0].

        voice_style : typing.Optional[float]
            For models that support it, the voice style value to use. This will default to 1.0, with a valid range of [0.0, 1.0].

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

        Returns
        -------
        HttpResponse[SpeakerCreatedResponse]
            Successful Response
        r+   /speakerPOSTr    r!   r"   r#   r$   r/   r0   r1   r6   r7   r8   r;   r>   r?   rA   )r   rC   rD   r
   rE   rB   rF   rG   r   r   r3   r	   r   rH   r4   r   r   r   rI   r   r'   r    r!   r"   r#   r$   r&   rK   rL   rM   s              r   createzRawSpeakerClient.createw   sk   P ((55=="#3J#?"@I ,$#2$4*  2 , > 
	 	ti++1c1*"4 ) 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 r&   c                    | j                   j                  j                  dt        |       dt        |       d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                        |      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)a  
        Fetch the top 10 similar voices to a speaker, including the voice IDs, names, descriptions, and, where possible, a sample audio recording.

        Parameters
        ----------
        dubbing_id : str
            ID of the dubbing project.

        speaker_id : str
            ID of the speaker.

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

        Returns
        -------
        HttpResponse[SimilarVoicesForSpeakerResponse]
            Successful Response
        r+   r,   /similar-voicesGETr2   r&   r6   r7   r8   r;   r>   r?   rA   )r   rC   rD   r
   rB   rF   rG   r   r   r3   r	   r   rH   r4   r   r   r   rI   r   r'   r(   r&   rK   rL   rM   s          r   find_similar_voicesz$RawSpeakerClient.find_similar_voices   sS   , ((55=="#3J#?"@	JZ[eJfIggvw+ > 
	
	ti++1c13"= ) 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   rE   strrF   OptionalfloatSequencer   r	   r   rN   r   rU   r   r\    r   r   r   r      s   .*; . .2)-2637.2;?;?[p[p [p
 ooc*[p //#&[p  /[p !//%0[p __U+[p ??6??3#78[p  8[p 
,	-[pB .2)-2637.2;?PpPp ooc*	Pp
 //#&Pp  /Pp !//%0Pp __U+Pp  8Pp 
,	-Ppf gk3p3p+.3pDJOOTbDc3p	5	63pr   r   c                   H   e Zd ZdefdZeeeeeedddededej                  e   dej                  e   d	ej                  e	   d
ej                  e	   dej                  e	   dej                  ej                  e      dej                  e   dee   fdZeeeeedddedej                  e   dej                  e   d	ej                  e	   d
ej                  e	   dej                  e	   dej                  e   dee   fdZdddededej                  e   dee   fdZy)AsyncRawSpeakerClientr   c                    || _         y r   r   r   s     r   r   zAsyncRawSpeakerClient.__init__   r   r   Nr   r'   r(   r    r!   r"   r#   r$   r%   r&   r)   c                <  K   | j                   j                  j                  dt        |       dt        |       d||||||d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  
        Amend the metadata associated with a speaker, such as their voice. Both voice cloning and using voices from the ElevenLabs library are supported.

        Parameters
        ----------
        dubbing_id : str
            ID of the dubbing project.

        speaker_id : str
            ID of the speaker.

        speaker_name : typing.Optional[str]
            Name to attribute to this speaker.

        voice_id : typing.Optional[str]
            Either the identifier of a voice from the ElevenLabs voice library, or one of ['track-clone', 'clip-clone'].

        voice_stability : typing.Optional[float]
            For models that support it, the voice similarity value to use. This will default to 0.65, with a valid range of [0.0, 1.0].

        voice_similarity : typing.Optional[float]
            For models that support it, the voice similarity value to use. This will default to 1.0, with a valid range of [0.0, 1.0].

        voice_style : typing.Optional[float]
            For models that support it, the voice style value to use. This will default to 1.0, with a valid range of [0.0, 1.0].

        languages : typing.Optional[typing.Sequence[str]]
            Languages to apply these changes to. If empty, will apply to all languages.

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

        Returns
        -------
        AsyncHttpResponse[SpeakerUpdatedResponse]
            Successful Response
        r+   r,   r-   r.   r/   r0   r1   Nr6   r7   r8   r;   r>   r?   rA   )r   rC   rD   r
   rE   rB   rF   rG   r   r   r3   r   r   rH   r4   r   r   r   rI   rJ   s                r   rN   zAsyncRawSpeakerClient.update  s    d ..;;CC"#3J#?"@	JZ[eJfIgh ,$#2$4*&  2 , D 
 
	"	ti++1c1*"4 ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooS
N  	ty'<'<d9K\K\F]dmdrdrss	ts8   AFEFAE 7F8A4E ,,F?FFrO   c                $  K   | j                   j                  j                  dt        |       dd|||||d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)ak  
        Parameters
        ----------
        dubbing_id : str
            ID of the dubbing project.

        speaker_name : typing.Optional[str]
            Name to attribute to this speaker.

        voice_id : typing.Optional[str]
            Either the identifier of a voice from the ElevenLabs voice library, or one of ['track-clone', 'clip-clone'].

        voice_stability : typing.Optional[float]
            For models that support it, the voice similarity value to use. This will default to 0.65, with a valid range of [0.0, 1.0].

        voice_similarity : typing.Optional[float]
            For models that support it, the voice similarity value to use. This will default to 1.0, with a valid range of [0.0, 1.0].

        voice_style : typing.Optional[float]
            For models that support it, the voice style value to use. This will default to 1.0, with a valid range of [0.0, 1.0].

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

        Returns
        -------
        AsyncHttpResponse[SpeakerCreatedResponse]
            Successful Response
        r+   rQ   rR   rS   r/   r0   r1   Nr6   r7   r8   r;   r>   r?   rA   )r   rC   rD   r
   rE   rB   rF   rG   r   r   r3   r   r   rH   r4   r   r   r   rI   rT   s              r   rU   zAsyncRawSpeakerClient.create`  s{    P ..;;CC"#3J#?"@I ,$#2$4*  2 , D 
 
	 	ti++1c1*"4 ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooQ
L  	ty'<'<d9K\K\F]dmdrdrss	ts8   AF
EFAE +F,A4E  ,F?FFrV   c                  K   | j                   j                  j                  dt        |       dt        |       dd|       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  
        Fetch the top 10 similar voices to a speaker, including the voice IDs, names, descriptions, and, where possible, a sample audio recording.

        Parameters
        ----------
        dubbing_id : str
            ID of the dubbing project.

        speaker_id : str
            ID of the speaker.

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

        Returns
        -------
        AsyncHttpResponse[SimilarVoicesForSpeakerResponse]
            Successful Response
        r+   r,   rX   rY   rZ   Nr6   r7   r8   r;   r>   r?   rA   )r   rC   rD   r
   rB   rF   rG   r   r   r3   r   r   rH   r4   r   r   r   rI   r[   s          r   r\   z)AsyncRawSpeakerClient.find_similar_voices  sa    , ..;;CC"#3J#?"@	JZ[eJfIggvw+ D 
 
	
	ti++1c13"= ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	ts8   AFEFAE (F)A4E ,F?F

F)r]   r^   r_   r   r   rE   r`   rF   ra   rb   rc   r   r   r   rN   r   rU   r   r\   rd   r   r   rf   rf      s   .*< . .2)-2637.2;?;?[p[p [p
 ooc*[p //#&[p  /[p !//%0[p __U+[p ??6??3#78[p  8[p 
1	2[pB .2)-2637.2;?PpPp ooc*	Pp
 //#&Pp  /Pp !//%0Pp __U+Pp  8Pp 
1	2Ppf gk3p3p+.3pDJOOTbDc3p	:	;3pr   rf   ) rF   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.jsonable_encoderr
   core.request_optionsr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr   types.http_validation_errorr   )types.similar_voices_for_speaker_responser   types.speaker_created_responser   types.speaker_updated_responser   rG   AnyrE   r   rf   rd   r   r   <module>rx      sc     ( ' I B 6 3 8 J ? Y E E v{{6::s#fp fpRfp fpr   