o
    lWigH                     @   s   d dl Z d dlm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   )core)ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)UnprocessableEntityError)AddVoiceResponseModel)DeleteVoiceSampleResponseModel)HttpValidationError)VoiceSample.c                   @      e Zd ZdefddZedddedeje	j
 deje d	eje d
eeje  f
ddZeeeeedddededeje dej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 )RawSamplesClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   l/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/voices/pvc/samples/raw_client.py__init__      
zRawSamplesClient.__init__Nremove_background_noiserequest_optionsvoice_idfilesr    r!   returnc             	   C   s   | j jjdt| ddd|id|i|tdd}zDd|j  kr$d	k r?n nttjt	 t
tjt	 | d
}t||dW S |jdkrWtt|jttt
t| d
d| }W n tyo   t|jt|j|jdw t|jt|j|d)a  
        Add audio samples to a PVC 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.

        files : typing.List[core.File]
            See core.File for more documentation

        remove_background_noise : typing.Optional[bool]
            If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse.

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

        Returns
        -------
        HttpResponse[typing.List[VoiceSample]]
            Successful Response
        v1/voices/pvc//samplesPOSTr    r#   Tmethoddatar#   r!   omitforce_multipart   ,  type_object_responser*     headersbodystatus_coder6   r7   )r   httpx_clientrequestr
   OMITr9   typingcastListr   r   jsonr	   r   dictr6   r   r   r   textr   r"   r#   r    r!   	_response_data_response_jsonr   r   r   create   sJ   

zRawSamplesClient.creater    selected_speaker_idstrim_start_timetrim_end_time	file_namer!   	sample_idrI   rJ   rK   rL   c             	   C   s   | j jjdt| 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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  
        Update a PVC voice sample - apply noise removal, select speaker, change trim times or file name.

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

        sample_id : str
            Sample ID to be used

        remove_background_noise : typing.Optional[bool]
            If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse.

        selected_speaker_ids : typing.Optional[typing.Sequence[str]]
            Speaker IDs to be used for PVC training. Make sure you send all the speaker IDs you want to use for PVC training in one request because the last request will override the previous ones.

        trim_start_time : typing.Optional[int]
            The start time of the audio to be used for PVC training. Time should be in milliseconds

        trim_end_time : typing.Optional[int]
            The end time of the audio to be used for PVC training. Time should be in milliseconds

        file_name : typing.Optional[str]
            The name of the audio file to be used for PVC training.

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

        Returns
        -------
        HttpResponse[AddVoiceResponseModel]
            Successful Response
        r%   	/samples/r'   r    rI   rJ   rK   rL   content-typeapplication/jsonr)   r@   r6   r!   r+   r-   r.   r/   r2   r4   r5   r8   )r   r:   r;   r
   r<   r9   r=   r>   r   r   r@   r	   r   rA   r6   r   r   r   rB   r   r"   rM   r    rI   rJ   rK   rL   r!   rD   rE   rF   r   r   r   update`   sP   .

zRawSamplesClient.updater!   c             	   C   s   | j jjdt| dt| d|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  
        Delete a sample from a PVC 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.

        sample_id : str
            Sample ID to be used

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

        Returns
        -------
        HttpResponse[DeleteVoiceSampleResponseModel]
            Successful Response
        r%   rN   DELETEr)   r!   r-   r.   r/   r2   r4   r5   r8   )r   r:   r;   r
   r9   r=   r>   r   r   r@   r	   r   rA   r6   r   r   r   rB   r   r"   rM   r!   rD   rE   rF   r   r   r   delete   s>   

zRawSamplesClient.delete)__name__
__module____qualname__r   r   r<   strr=   r?   r   FileOptionalboolr   r	   r   rG   Sequenceintr   rT   r   rY   r   r   r   r   r      d    

J	

Yr   c                   @   r   )AsyncRawSamplesClientr   c                C   r   r   r   r   r   r   r   r      r   zAsyncRawSamplesClient.__init__Nr   r"   r#   r    r!   r$   c             	      s   | j jjdt| ddd|id|i|tddI dH }zDd	|j  kr(d
k rCn nttjt	 t
tjt	 | d}t||dW S |jdkr[tt|jttt
t| dd| }W n tys   t|jt|j|jdw t|jt|j|d)a  
        Add audio samples to a PVC 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.

        files : typing.List[core.File]
            See core.File for more documentation

        remove_background_noise : typing.Optional[bool]
            If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse.

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

        Returns
        -------
        AsyncHttpResponse[typing.List[VoiceSample]]
            Successful Response
        r%   r&   r'   r    r#   Tr(   Nr-   r.   r/   r2   r4   r5   r8   )r   r:   r;   r
   r<   r9   r=   r>   r?   r   r   r@   r   r   rA   r6   r   r   r   rB   rC   r   r   r   rG      sL   

zAsyncRawSamplesClient.createrH   rM   rI   rJ   rK   rL   c             	      s   | j jjdt| dt| d|||||d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  
        Update a PVC voice sample - apply noise removal, select speaker, change trim times or file name.

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

        sample_id : str
            Sample ID to be used

        remove_background_noise : typing.Optional[bool]
            If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse.

        selected_speaker_ids : typing.Optional[typing.Sequence[str]]
            Speaker IDs to be used for PVC training. Make sure you send all the speaker IDs you want to use for PVC training in one request because the last request will override the previous ones.

        trim_start_time : typing.Optional[int]
            The start time of the audio to be used for PVC training. Time should be in milliseconds

        trim_end_time : typing.Optional[int]
            The end time of the audio to be used for PVC training. Time should be in milliseconds

        file_name : typing.Optional[str]
            The name of the audio file to be used for PVC training.

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

        Returns
        -------
        AsyncHttpResponse[AddVoiceResponseModel]
            Successful Response
        r%   rN   r'   rO   rP   rQ   rR   Nr-   r.   r/   r2   r4   r5   r8   )r   r:   r;   r
   r<   r9   r=   r>   r   r   r@   r   r   rA   r6   r   r   r   rB   rS   r   r   r   rT   7  sR   .

zAsyncRawSamplesClient.updaterU   c             	      s   | j jjdt| dt| d|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   
        Delete a sample from a PVC 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.

        sample_id : str
            Sample ID to be used

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

        Returns
        -------
        AsyncHttpResponse[DeleteVoiceSampleResponseModel]
            Successful Response
        r%   rN   rV   rW   Nr-   r.   r/   r2   r4   r5   r8   )r   r:   r;   r
   r9   r=   r>   r   r   r@   r   r   rA   r6   r   r   r   rB   rX   r   r   r   rY     s@   

zAsyncRawSamplesClient.delete)rZ   r[   r\   r   r   r<   r]   r=   r?   r   r^   r_   r`   r   r   r   rG   ra   rb   r   rT   r   rY   r   r   r   r   rd      rc   rd   )"r=   json.decoderr    r   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.delete_voice_sample_response_modelr   types.http_validation_errorr   types.voice_sampler   r>   Anyr<   r   rd   r   r   r   r   <module>   s$    X