
    b6ix                     N   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 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 jN                  e jP                  d      Z) G d d      Z* G d d      Z+y)    N)JSONDecodeError   )core)ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)UnprocessableEntityError)DeleteDubbingResponseModel)DoDubbingResponse) DubbingMetadataPageResponseModel)DubbingMetadataResponse)HttpValidationError   )DubbingCreateRequestMode)DubbingListRequestDubbingStatus)!DubbingListRequestFilterByCreator) DubbingListRequestOrderDirection.c            .          e Zd ZdefdZdddddddddej                  e   dej                  e   dej                  e	   dej                  e
   d	ej                  ej                  d
      dej                  e   dej                  e   dee   fdZeeeeeeeeeeeeeeeeeeeedddej                  ej&                     dej                  ej&                     dej                  ej&                     dej                  ej&                     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j                  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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j                  e   dee   fd'Zdd%d&edej                  e   dee   fd(Zy))RawDubbingClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     h/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/dubbing/raw_client.py__init__zRawDubbingClient.__init__   
    -    Ncursor	page_sizedubbing_statusfilter_by_creatororder_byorder_directionrequest_optionsr'   r(   r)   r*   r+   
created_atr,   r-   returnc                   | j                   j                  j                  d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                        |
      # t        $ r6 t        |j                  t        |j                        |j                         w xY w)a  
        List the dubs you have access to.

        Parameters
        ----------
        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

        page_size : typing.Optional[int]
            How many dubs to return at maximum. Can not exceed 200, defaults to 100.

        dubbing_status : typing.Optional[DubbingListRequestDubbingStatus]
            What state the dub is currently in.

        filter_by_creator : typing.Optional[DubbingListRequestFilterByCreator]
            Filters who created the resources being listed, whether it was the user running the request or someone else that shared the resource with them.

        order_by : typing.Optional[typing.Literal["created_at"]]
            The field to use for ordering results from this query.

        order_direction : typing.Optional[DubbingListRequestOrderDirection]
            The order direction to use for results from this query.

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

        Returns
        -------
        HttpResponse[DubbingMetadataPageResponseModel]
            Successful Response
        
v1/dubbingGETr'   r(   r)   r*   r+   r,   methodparamsr-      ,  type_object_responsedata  headersbodystatus_coderA   rB   )r   httpx_clientrequestrD   typingcastr   r   jsonr
   r   dictrA   r   r   r   textr!   r'   r(   r)   r*   r+   r,   r-   	_response_data_response_jsons              r"   listzRawDubbingClient.list    sN   T ((55== &"0%6$#2 , > 
		ti++1c14"> ) 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,filecsv_fileforeground_audio_filebackground_audio_filename
source_urlsource_langtarget_langtarget_accentnum_speakers	watermark
start_timeend_timehighest_resolutiondrop_background_audiouse_profanity_filterdubbing_studiodisable_voice_cloningmodecsv_fpsr-   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   c                ~   | j                   j                  j                  ddi d|d|d|d|d|	d|
d	|d
|d|d|d|d|d|d|d|d|i |d|ini |d|ini |d|ini |d|in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                        |      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w) a?  
        Dubs a provided audio or video file into given language.

        Parameters
        ----------
        file : typing.Optional[core.File]
            See core.File for more documentation

        csv_file : typing.Optional[core.File]
            See core.File for more documentation

        foreground_audio_file : typing.Optional[core.File]
            See core.File for more documentation

        background_audio_file : typing.Optional[core.File]
            See core.File for more documentation

        name : typing.Optional[str]
            Name of the dubbing project.

        source_url : typing.Optional[str]
            URL of the source video/audio file.

        source_lang : typing.Optional[str]
            Source language. Expects a valid iso639-1 or iso639-3 language code.

        target_lang : typing.Optional[str]
            The Target language to dub the content into. Expects a valid iso639-1 or iso639-3 language code.

        target_accent : typing.Optional[str]
            [Experimental] An accent to apply when selecting voices from the library and to use to inform translation of the dialect to prefer.

        num_speakers : typing.Optional[int]
            Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers

        watermark : typing.Optional[bool]
            Whether to apply watermark to the output video.

        start_time : typing.Optional[int]
            Start time of the source video/audio file.

        end_time : typing.Optional[int]
            End time of the source video/audio file.

        highest_resolution : typing.Optional[bool]
            Whether to use the highest resolution available.

        drop_background_audio : typing.Optional[bool]
            An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues.

        use_profanity_filter : typing.Optional[bool]
            [BETA] Whether transcripts should have profanities censored with the words '[censored]'

        dubbing_studio : typing.Optional[bool]
            Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource.

        disable_voice_cloning : typing.Optional[bool]
            Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. Voices used from the library will contribute towards a workspace's custom voices limit, and if there aren't enough available slots the dub will fail. Using this feature requires the caller to have the 'add_voice_from_voice_library' permission on their workspace to access new voices.

        mode : typing.Optional[DubbingCreateRequestMode]
            The mode in which to run this Dubbing job. Defaults to automatic, use manual if specifically providing a CSV transcript to use. Note that manual mode is experimental and production use is strongly discouraged.

        csv_fps : typing.Optional[float]
            Frames per second to use when parsing a CSV file for dubbing. If not provided, FPS will be inferred from timecodes.

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

        Returns
        -------
        HttpResponse[DoDubbingResponse]
            Successful Response
        r1   POSTrV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rR   rS   rT   rU   Tr5   r>   filesr-   omitforce_multipartr7   r8   r9   r<   r?   r@   rC   )r   rE   rF   OMITrD   rG   rH   r   r   rI   r
   r   rJ   rA   r   r   r   rK   r!   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   r-   rM   rN   rO   s                            r"   createzRawDubbingClient.createq   sd   D ((55==j { {	
    Y j H %&8 ()> '(< !. ()>   7!$%)%5FD>2-5-AJ)r H]Gh+-BCnp H]Gh+-BCnp	 , ; > 
	>	ti++1c1%"/ ) 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= A4E= =?F<r-   
dubbing_idc                   | j                   j                  j                  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  
        Returns metadata about a dubbing project, including whether it's still in progress or not

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

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

        Returns
        -------
        HttpResponse[DubbingMetadataResponse]
            Successful Response
        v1/dubbing/r2   r5   r-   r7   r8   r9   r<   r?   r@   rC   )r   rE   rF   r   rD   rG   rH   r   r   rI   r
   r   rJ   rA   r   r   r   rK   r!   rp   r-   rM   rN   rO   s         r"   getzRawDubbingClient.get  sB   & ((55==*:678+ > 
	
	ti++1c1+"5 ) 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   AD1 A4D1 1?E0c                   | j                   j                  j                  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)al  
        Deletes a dubbing project.

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

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

        Returns
        -------
        HttpResponse[DeleteDubbingResponseModel]
            Successful Response
        rr   DELETErs   r7   r8   r9   r<   r?   r@   rC   )r   rE   rF   r   rD   rG   rH   r   r   rI   r
   r   rJ   rA   r   r   r   rK   rt   s         r"   deletezRawDubbingClient.delete>  sB   & ((55==*:678+ > 
	
	ti++1c1."8 ) 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rv   )__name__
__module____qualname__r   r#   rG   Optionalstrintr   r   Literalr   r   r
   r   rP   rl   r   Fileboolr   floatr   rn   r   ru   r   ry    r%   r"   r   r      ss   .*; . (,*.KOPTBFMQ;?Op $Op ??3'	Op
 (GHOp "??+LMOp //&..">?Op  )IJOp  8Op 
6	7Oph ,0/3<@<@%)+/,0,0.2-1+/+/)-487;6:047;:>*.;?/Yp oodii(Yp //$)),	Yp
  &tyy9Yp  &tyy9Yp ooc"Yp OOC(Yp __S)Yp __S)Yp s+Yp ooc*Yp ??4(Yp OOC(Yp //#&Yp  #OOD1!Yp"  &t4#Yp$ %ood3%Yp& -'Yp(  &t4)Yp* oo67+Yp, '-Yp.  8/Yp0 
'	(1Ypx VZ0p0p39??>3R0p	-	.0pf VZ0p0p39??>3R0p	0	10pr%   r   c            .          e Zd ZdefdZdddddddddej                  e   dej                  e   dej                  e	   dej                  e
   d	ej                  ej                  d
      dej                  e   dej                  e   dee   fdZeeeeeeeeeeeeeeeeeeeedddej                  ej&                     dej                  ej&                     dej                  ej&                     dej                  ej&                     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j                  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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j                  e   dee   fd'Zdd%d&edej                  e   dee   fd(Zy))AsyncRawDubbingClientr   c                    || _         y r   r   r    s     r"   r#   zAsyncRawDubbingClient.__init__r  r$   r%   Nr&   r'   r(   r)   r*   r+   r.   r,   r-   r/   c                  K   | j                   j                  j                  dd||||||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  
        List the dubs you have access to.

        Parameters
        ----------
        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

        page_size : typing.Optional[int]
            How many dubs to return at maximum. Can not exceed 200, defaults to 100.

        dubbing_status : typing.Optional[DubbingListRequestDubbingStatus]
            What state the dub is currently in.

        filter_by_creator : typing.Optional[DubbingListRequestFilterByCreator]
            Filters who created the resources being listed, whether it was the user running the request or someone else that shared the resource with them.

        order_by : typing.Optional[typing.Literal["created_at"]]
            The field to use for ordering results from this query.

        order_direction : typing.Optional[DubbingListRequestOrderDirection]
            The order direction to use for results from this query.

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

        Returns
        -------
        AsyncHttpResponse[DubbingMetadataPageResponseModel]
            Successful Response
        r1   r2   r3   r4   Nr7   r8   r9   r<   r?   r@   rC   )r   rE   rF   rD   rG   rH   r   r   rI   r	   r   rJ   rA   r   r   r   rK   rL   s              r"   rP   zAsyncRawDubbingClient.listu  s^    T ..;;CC &"0%6$#2 , D 
 
		ti++1c14"> ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooK
F  	ty'<'<d9K\K\F]dmdrdrss	ts4   4E<D7E<AD: E<A4D: ,E<:?E99E<rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   c                  K   | j                   j                  j                  ddi d|d|d|d|d|	d|
d	|d
|d|d|d|d|d|d|d|d|i |d|ini |d|ini |d|ini |d|ini |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)!aD  
        Dubs a provided audio or video file into given language.

        Parameters
        ----------
        file : typing.Optional[core.File]
            See core.File for more documentation

        csv_file : typing.Optional[core.File]
            See core.File for more documentation

        foreground_audio_file : typing.Optional[core.File]
            See core.File for more documentation

        background_audio_file : typing.Optional[core.File]
            See core.File for more documentation

        name : typing.Optional[str]
            Name of the dubbing project.

        source_url : typing.Optional[str]
            URL of the source video/audio file.

        source_lang : typing.Optional[str]
            Source language. Expects a valid iso639-1 or iso639-3 language code.

        target_lang : typing.Optional[str]
            The Target language to dub the content into. Expects a valid iso639-1 or iso639-3 language code.

        target_accent : typing.Optional[str]
            [Experimental] An accent to apply when selecting voices from the library and to use to inform translation of the dialect to prefer.

        num_speakers : typing.Optional[int]
            Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers

        watermark : typing.Optional[bool]
            Whether to apply watermark to the output video.

        start_time : typing.Optional[int]
            Start time of the source video/audio file.

        end_time : typing.Optional[int]
            End time of the source video/audio file.

        highest_resolution : typing.Optional[bool]
            Whether to use the highest resolution available.

        drop_background_audio : typing.Optional[bool]
            An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues.

        use_profanity_filter : typing.Optional[bool]
            [BETA] Whether transcripts should have profanities censored with the words '[censored]'

        dubbing_studio : typing.Optional[bool]
            Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource.

        disable_voice_cloning : typing.Optional[bool]
            Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. Voices used from the library will contribute towards a workspace's custom voices limit, and if there aren't enough available slots the dub will fail. Using this feature requires the caller to have the 'add_voice_from_voice_library' permission on their workspace to access new voices.

        mode : typing.Optional[DubbingCreateRequestMode]
            The mode in which to run this Dubbing job. Defaults to automatic, use manual if specifically providing a CSV transcript to use. Note that manual mode is experimental and production use is strongly discouraged.

        csv_fps : typing.Optional[float]
            Frames per second to use when parsing a CSV file for dubbing. If not provided, FPS will be inferred from timecodes.

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

        Returns
        -------
        AsyncHttpResponse[DoDubbingResponse]
            Successful Response
        r1   rg   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   NrR   rS   rT   rU   Trh   r7   r8   r9   r<   r?   r@   rC   )r   rE   rF   rl   rD   rG   rH   r   r   rI   r	   r   rJ   rA   r   r   r   rK   rm   s                            r"   rn   zAsyncRawDubbingClient.create  st    D ..;;CCj { {	
    Y j H %&8 ()> '(< !. ()>   7!$%)%5FD>2-5-AJ)r H]Gh+-BCnp H]Gh+-BCnp	 , ; D 
 
	>	ti++1c1%"/ ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooo
j  	ty'<'<d9K\K\F]dmdrdrss	ts8   BGFGAF
 'G(A4F
 ,G
?G		Gro   rp   c                  K   | j                   j                  j                  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  
        Returns metadata about a dubbing project, including whether it's still in progress or not

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

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

        Returns
        -------
        AsyncHttpResponse[DubbingMetadataResponse]
            Successful Response
        rr   r2   rs   Nr7   r8   r9   r<   r?   r@   rC   )r   rE   rF   r   rD   rG   rH   r   r   rI   r	   r   rJ   rA   r   r   r   rK   rt   s         r"   ru   zAsyncRawDubbingClient.geta  sP    & ..;;CC*:678+ D 
 
	
	ti++1c1+"5 ) 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5   8F D;F  AD> F A4D> ,F >?E==F c                  K   | j                   j                  j                  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)aq  
        Deletes a dubbing project.

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

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

        Returns
        -------
        AsyncHttpResponse[DeleteDubbingResponseModel]
            Successful Response
        rr   rx   rs   Nr7   r8   r9   r<   r?   r@   rC   )r   rE   rF   r   rD   rG   rH   r   r   rI   r	   r   rJ   rA   r   r   r   rK   rt   s         r"   ry   zAsyncRawDubbingClient.delete  sP    & ..;;CC*:678+ D 
 
	
	ti++1c1."8 ) 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r   )rz   r{   r|   r   r#   rG   r}   r~   r   r   r   r   r   r   r	   r   rP   rl   r   r   r   r   r   r   rn   r   ru   r   ry   r   r%   r"   r   r   q  ss   .*< . (,*.KOPTBFMQ;?Op $Op ??3'	Op
 (GHOp "??+LMOp //&..">?Op  )IJOp  8Op 
;	<Oph ,0/3<@<@%)+/,0,0.2-1+/+/)-487;6:047;:>*.;?/Yp oodii(Yp //$)),	Yp
  &tyy9Yp  &tyy9Yp ooc"Yp OOC(Yp __S)Yp __S)Yp s+Yp ooc*Yp ??4(Yp OOC(Yp //#&Yp  #OOD1!Yp"  &t4#Yp$ %ood3%Yp& -'Yp(  &t4)Yp* oo67+Yp, '-Yp.  8/Yp0 
,	-1Ypx VZ0p0p39??>3R0p	2	30pf VZ0p0p39??>3R0p	5	60pr%   r   ),rG   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.delete_dubbing_response_modelr   types.do_dubbing_responser   *types.dubbing_metadata_page_response_modelr   types.dubbing_metadata_responser   types.http_validation_errorr   !types.dubbing_create_request_moder   )types.dubbing_list_request_dubbing_statusr   ,types.dubbing_list_request_filter_by_creatorr   *types.dubbing_list_request_order_directionr   rH   Anyrl   r   r   r   r%   r"   <module>r      su     (  % G @ 4 1 6 H L 9 Y E = G V [ X v{{6::s#Rp Rpj
Rp Rpr%   