o
    lWiN                     @   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)construct_type)UnprocessableEntityError)HttpValidationError)SimilarVoicesForSpeakerResponse)SpeakerCreatedResponse)SpeakerUpdatedResponse.c                   @     e Zd Zdefd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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dZdddededeje dee fddZdS )RawSpeakerClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   r/var/www/html/asistente-voz-ia/venv/lib/python3.10/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             
   C   s   | j jjdt| dt| d||||||dddi|	td}
z>d|
j  kr,d	k rAn nttt	t|

 d
}t|
|dW S |
jdkrYtt|
jttt	t|

 d
d|

 }W n tyq   t|
jt|
j|
jdw t|
jt|
j|d)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  r2   bodystatus_coder2   r>   )r   httpx_clientrequestr	   OMITr@   typingcastr   r   r1   r   r   dictr2   r   r   r   textr   r&   r'   r   r    r!   r"   r#   r$   r%   	_response_data_response_jsonr   r   r   update   sR   2	

zRawSpeakerClient.updater   r    r!   r"   r#   r%   c             	   C   s   | j jjdt| dd|||||d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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)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-   r.   r/   r4   r5   r6   r9   r<   r=   r?   )r   rA   rB   r	   rC   r@   rD   rE   r   r   r1   r   r   rF   r2   r   r   r   rG   r   r&   r   r    r!   r"   r#   r%   rI   rJ   rK   r   r   r   createw   sP   (

zRawSpeakerClient.creater%   c             	   C   s   | j jjdt| dt| dd|d}z>d|j  kr!dk r6n ntttt|	 d}t
||d	W S |jd
krNtt|jtttt|	 dd|	 }W n tyf   t|jt|j|jdw t|jt|j|d)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r0   r%   r4   r5   r6   r9   r<   r=   r?   )r   rA   rB   r	   r@   rD   rE   r   r   r1   r   r   rF   r2   r   r   r   rG   r   r&   r'   r%   rI   rJ   rK   r   r   r   find_similar_voices   s>   

z$RawSpeakerClient.find_similar_voices)__name__
__module____qualname__r   r   rC   strrD   OptionalfloatSequencer
   r   r   rL   r   rR   r   rX   r   r   r   r   r      ~    	

a	

Sr   c                   @   r   )AsyncRawSpeakerClientr   c                C   r   r   r   r   r   r   r   r      r   zAsyncRawSpeakerClient.__init__Nr   r&   r'   r   r    r!   r"   r#   r$   r%   r(   c             
      s  | j jjdt| dt| d||||||dddi|	tdI dH }
z>d	|
j  kr0d
k rEn 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yu   t|
jt|
j|
jdw t|
jt|
j|d)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-   r.   r/   Nr4   r5   r6   r9   r<   r=   r?   )r   rA   rB   r	   rC   r@   rD   rE   r   r   r1   r   r   rF   r2   r   r   r   rG   rH   r   r   r   rL     sT   2	

zAsyncRawSpeakerClient.updaterM   c             	      s   | j jjdt| dd|||||d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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)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)   rN   rO   rP   r-   r.   r/   Nr4   r5   r6   r9   r<   r=   r?   )r   rA   rB   r	   rC   r@   rD   rE   r   r   r1   r   r   rF   r2   r   r   r   rG   rQ   r   r   r   rR   `  sR   (

zAsyncRawSpeakerClient.createrS   c             	      s   | j jjdt| dt| dd|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rRtt|jtttt|	 d	d|	 }W n tyj   t|jt|j|jdw t|jt|j|d)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*   rT   rU   rV   Nr4   r5   r6   r9   r<   r=   r?   )r   rA   rB   r	   r@   rD   rE   r   r   r1   r   r   rF   r2   r   r   r   rG   rW   r   r   r   rX     s@   

z)AsyncRawSpeakerClient.find_similar_voices)rY   rZ   r[   r   r   rC   r\   rD   r]   r^   r_   r
   r   r   rL   r   rR   r   rX   r   r   r   r   ra      r`   ra   ) rD   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   rE   AnyrC   r   ra   r   r   r   r   <module>   s"    j