
    b6i*                         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 j2                  e j4                  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)SegmentDeleteResponse)SegmentUpdateResponse.c                       e Zd Zdef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Zdddededej                  e
   dee   fdZy)RawSegmentClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     y/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/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                0   | j                   j                  j                  dt        |       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  
        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  r2   bodystatus_coder2   r>   )r   httpx_clientrequestr
   OMITr@   typingcastr   r   r1   r	   r   dictr2   r   r   r   r!   r   r#   r$   r%   r   r    r!   r"   	_response_data_response_jsons              r   updatezRawSegmentClient.update   s   N ((55=="#3J#?"@	JZ[eJfIgghiy  {C  jD  iE  F($  2 , > 
		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E 7A4E ?Fr"   c                   | j                   j                  j                  dt        |       d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                        |      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)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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   r!   r   r#   r$   r"   rH   rI   rJ   s          r   deletezRawSegmentClient.deleteh   sP   , ((55=="#3J#?"@	JZ[eJfIgh+ > 
	
	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   rC   strrD   Optionalfloatr   r	   r   rK   r   rQ    r   r   r   r      s    .*; . .2+/%);?MpMp Mp 	Mp OOE*Mp //%(Mp ooc"Mp  8Mp 
+	,Mp` gk3p3p+.3pDJOOTbDc3p	+	,3pr   r   c                       e Zd Zdef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Zdddededej                  e
   dee   fdZy)AsyncRawSegmentClientr   c                    || _         y r   r   r   s     r   r   zAsyncRawSegmentClient.__init__   r   r   Nr   r#   r$   r%   r   r    r!   r"   r&   c                N  K   | j                   j                  j                  dt        |       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  
        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/   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   r!   rG   s              r   rK   zAsyncRawSegmentClient.update   s    N ..;;CC"#3J#?"@	JZ[eJfIgghiy  {C  jD  iE  F($  2 , D 
 
		ti++1c1)"3 ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooM
H  	ty'<'<d9K\K\F]dmdrdrss	ts8   AF%E  F%%AE#  F%A4E# 5,F%#?F""F%rL   c                  K   | 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                        |      7 # t        $ r6 t!        |j                  t        |j                        |j"                        w xY ww)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)   rN   rO   Nr4   r5   r6   r9   r<   r=   r?   )r   rA   rB   r
   r@   rD   rE   r   r   r1   r   r   rF   r2   r   r   r   r!   rP   s          r   rQ   zAsyncRawSegmentClient.delete   s^    , ..;;CC"#3J#?"@	JZ[eJfIgh+ 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)rR   rS   rT   r   r   rC   rU   rD   rV   rW   r   r   r   rK   r   rQ   rX   r   r   rZ   rZ      s    .*< . .2+/%);?MpMp Mp 	Mp OOE*Mp //%(Mp ooc"Mp  8Mp 
0	1Mp` gk3p3p+.3pDJOOTbDc3p	0	13pr   rZ   )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.segment_delete_responser   types.segment_update_responser   rE   AnyrC   r   rZ   rX   r   r   <module>rj      s`     ( ' I B 6 3 8 J ? C C v{{6::s#Fp FpRFp Fpr   