o
    lWi*                     @   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)HttpValidationError)SegmentDeleteResponse)SegmentUpdateResponse.c                   @      e Zd ZdefddZeeedddeded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 )RawSegmentClient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/segment/raw_client.py__init__      
zRawSegmentClient.__init__N
start_timeend_timetextrequest_options
dubbing_id
segment_idlanguager   r   r    r!   returnc             	   C   s   | j jjdt| dt| dt| d|||dddi|td}z>d	|j  kr.d
k rCn 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ys   t|jt|j|jdw t|jt|j|
d)a  
        Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub.

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

        segment_id : str
            ID of the segment

        language : str
            ID of the language.

        start_time : typing.Optional[float]

        end_time : typing.Optional[float]

        text : typing.Optional[str]

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

        Returns
        -------
        HttpResponse[SegmentUpdateResponse]
            Successful Response
        v1/dubbing/resource/	/segment//PATCHr   r   r    content-typeapplication/jsonmethodjsonheadersr!   omit   ,  type_object_responsedata  r0   bodystatus_coder0   r<   )r   httpx_clientrequestr	   OMITr>   typingcastr   r   r/   r   r   dictr0   r   r   r   r    r   r"   r#   r$   r   r   r    r!   	_response_data_response_jsonr   r   r   update   sL   ' 

zRawSegmentClient.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  
        Deletes a single segment from the dubbing.

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

        segment_id : str
            ID of the segment

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

        Returns
        -------
        HttpResponse[SegmentDeleteResponse]
            Successful Response
        r&   r'   DELETEr.   r!   r2   r3   r4   r7   r:   r;   r=   )r   r?   r@   r	   r>   rB   rC   r   r   r/   r   r   rD   r0   r   r   r   r    r   r"   r#   r!   rF   rG   rH   r   r   r   deleteh   s>   

zRawSegmentClient.delete)__name__
__module____qualname__r   r   rA   strrB   Optionalfloatr
   r   r   rI   r   rN   r   r   r   r   r      B    		

Pr   c                   @   r   )AsyncRawSegmentClientr   c                C   r   r   r   r   r   r   r   r      r   zAsyncRawSegmentClient.__init__Nr   r"   r#   r$   r   r   r    r!   r%   c             	      s  | j jjdt| dt| dt| d|||dddi|tdI d	H }z>d
|j  kr2dk rGn 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yw   t|jt|j|jdw t|jt|j|
d)a  
        Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub.

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

        segment_id : str
            ID of the segment

        language : str
            ID of the language.

        start_time : typing.Optional[float]

        end_time : typing.Optional[float]

        text : typing.Optional[str]

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

        Returns
        -------
        AsyncHttpResponse[SegmentUpdateResponse]
            Successful Response
        r&   r'   r(   r)   r*   r+   r,   r-   Nr2   r3   r4   r7   r:   r;   r=   )r   r?   r@   r	   rA   r>   rB   rC   r   r   r/   r   r   rD   r0   r   r   r   r    rE   r   r   r   rI      sN   ' 

zAsyncRawSegmentClient.updaterJ   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  
        Deletes a single segment from the dubbing.

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

        segment_id : str
            ID of the segment

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

        Returns
        -------
        AsyncHttpResponse[SegmentDeleteResponse]
            Successful Response
        r&   r'   rK   rL   Nr2   r3   r4   r7   r:   r;   r=   )r   r?   r@   r	   r>   rB   rC   r   r   r/   r   r   rD   r0   r   r   r   r    rM   r   r   r   rN      s@   

zAsyncRawSegmentClient.delete)rO   rP   rQ   r   r   rA   rR   rB   rS   rT   r
   r   r   rI   r   rN   r   r   r   r   rV      rU   rV   )rB   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.segment_delete_responser   types.segment_update_responser   rC   AnyrA   r   rV   r   r   r   r   <module>   s     
