o
    lWiC                     @   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 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)AddVoiceResponseModel)HttpValidationError)"StartPvcVoiceTrainingResponseModel.c                   @     e Zd ZdefddZeedddededeje d	ejej	eeje f  d
eje
 dee fddZeeeedddedeje deje deje d	ejej	eeje f  d
eje
 dee fddZedddedeje d
eje
 dee fddZdS )RawPvcClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   d/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/voices/pvc/raw_client.py__init__      
zRawPvcClient.__init__Ndescriptionlabelsrequest_optionsnamelanguager   r   r    returnc          	   	   C   s   | j jjdd||||dddi|td}z>d|j  kr dk r5n ntttt|	 d	}t
||d
W S |jdkrMtt|jtttt|	 d	d|	 }W n tye   t|jt|j|jdw t|jt|j|d)a  
        Creates a new PVC voice with metadata but no samples

        Parameters
        ----------
        name : str
            The name that identifies this voice. This will be displayed in the dropdown of the website.

        language : str
            Language used in the samples.

        description : typing.Optional[str]
            Description to use for the created voice.

        labels : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Serialized labels dictionary for the voice.

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

        Returns
        -------
        HttpResponse[AddVoiceResponseModel]
            Successful Response
        v1/voices/pvcPOSTr!   r"   r   r   content-typeapplication/jsonmethodjsonheadersr    omit   ,  type_object_responsedata  r,   bodystatus_coder,   r8   )r   httpx_clientrequestOMITr:   typingcastr   r   r+   r   r   dictr,   r   r   r   text	r   r!   r"   r   r   r    	_response_data_response_jsonr   r   r   create   sN   "

zRawPvcClient.creater!   r"   r   r   r    voice_idc          
   	   C   s   | j jjdt| 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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)ar  
        Edit PVC voice metadata

        Parameters
        ----------
        voice_id : str
            Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

        name : typing.Optional[str]
            The name that identifies this voice. This will be displayed in the dropdown of the website.

        language : typing.Optional[str]
            Language used in the samples.

        description : typing.Optional[str]
            Description to use for the created voice.

        labels : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Serialized labels dictionary for the voice.

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

        Returns
        -------
        HttpResponse[AddVoiceResponseModel]
            Successful Response
        v1/voices/pvc/r%   r&   r'   r(   r)   r.   r/   r0   r3   r6   r7   r9   )r   r;   r<   r	   r=   r:   r>   r?   r   r   r+   r   r   r@   r,   r   r   r   rA   
r   rH   r!   r"   r   r   r    rC   rD   rE   r   r   r   updated   sN   &

zRawPvcClient.updatemodel_idr    rM   c             	   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(  
        Start PVC training process for a voice.

        Parameters
        ----------
        voice_id : str
            Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

        model_id : typing.Optional[str]
            The model ID to use for the conversion.

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

        Returns
        -------
        HttpResponse[StartPvcVoiceTrainingResponseModel]
            Successful Response
        rI   /trainr%   rM   r'   r(   r)   r.   r/   r0   r3   r6   r7   r9   )r   r;   r<   r	   r=   r:   r>   r?   r   r   r+   r   r   r@   r,   r   r   r   rA   r   rH   rM   r    rC   rD   rE   r   r   r   train   sH   

zRawPvcClient.train)__name__
__module____qualname__r   r   r=   strr>   OptionalDictr
   r   r   rF   rK   r   rP   r   r   r   r   r      b    
O	
Sr   c                   @   r   )AsyncRawPvcClientr   c                C   r   r   r   r   r   r   r   r      r   zAsyncRawPvcClient.__init__Nr   r!   r"   r   r   r    r#   c          	   	      s   | j jjdd||||dddi|tdI dH }z>d|j  kr$d	k r9n ntttt|	 d
}t
||dW S |jdkrQtt|jtttt|	 d
d|	 }W n tyi   t|jt|j|jdw t|jt|j|d)a  
        Creates a new PVC voice with metadata but no samples

        Parameters
        ----------
        name : str
            The name that identifies this voice. This will be displayed in the dropdown of the website.

        language : str
            Language used in the samples.

        description : typing.Optional[str]
            Description to use for the created voice.

        labels : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Serialized labels dictionary for the voice.

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

        Returns
        -------
        AsyncHttpResponse[AddVoiceResponseModel]
            Successful Response
        r$   r%   r&   r'   r(   r)   Nr.   r/   r0   r3   r6   r7   r9   )r   r;   r<   r=   r:   r>   r?   r   r   r+   r   r   r@   r,   r   r   r   rA   rB   r   r   r   rF      sP   "

zAsyncRawPvcClient.createrG   rH   c          
   	      s   | j jjdt| 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rVtt|jttt	t|
 d
d|
 }	W n tyn   t|jt|j|jdw t|jt|j|	d)aw  
        Edit PVC voice metadata

        Parameters
        ----------
        voice_id : str
            Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

        name : typing.Optional[str]
            The name that identifies this voice. This will be displayed in the dropdown of the website.

        language : typing.Optional[str]
            Language used in the samples.

        description : typing.Optional[str]
            Description to use for the created voice.

        labels : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Serialized labels dictionary for the voice.

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

        Returns
        -------
        AsyncHttpResponse[AddVoiceResponseModel]
            Successful Response
        rI   r%   r&   r'   r(   r)   Nr.   r/   r0   r3   r6   r7   r9   )r   r;   r<   r	   r=   r:   r>   r?   r   r   r+   r   r   r@   r,   r   r   r   rA   rJ   r   r   r   rK   C  sP   &

zAsyncRawPvcClient.updaterL   rM   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-  
        Start PVC training process for a voice.

        Parameters
        ----------
        voice_id : str
            Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

        model_id : typing.Optional[str]
            The model ID to use for the conversion.

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

        Returns
        -------
        AsyncHttpResponse[StartPvcVoiceTrainingResponseModel]
            Successful Response
        rI   rN   r%   rM   r'   r(   r)   Nr.   r/   r0   r3   r6   r7   r9   )r   r;   r<   r	   r=   r:   r>   r?   r   r   r+   r   r   r@   r,   r   r   r   rA   rO   r   r   r   rP     sJ   

zAsyncRawPvcClient.train)rQ   rR   rS   r   r   r=   rT   r>   rU   rV   r
   r   r   rF   rK   r   rP   r   r   r   r   rX      rW   rX   )r>   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.add_voice_response_modelr   types.http_validation_errorr   -types.start_pvc_voice_training_response_modelr   r?   Anyr=   r   rX   r   r   r   r   <module>   s     `