o
    lWiw                     @   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 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)DeleteDubbingResponseModel)DoDubbingResponse) DubbingMetadataPageResponseModel)DubbingMetadataResponse)HttpValidationError   )DubbingCreateRequestMode)DubbingListRequestDubbingStatus)!DubbingListRequestFilterByCreator) DubbingListRequestOrderDirection.c                .   @     e Zd Zdefd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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&d'Zdd(d)edeje dee fd*d+Zdd(d)edeje dee fd,d-ZdS ).RawDubbingClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r!   a/var/www/html/asistente-voz-ia/venv/lib/python3.10/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             
   C   s   | j jjdd||||||d|d}z>d|j  krdk r3n ntttt| d}	t	||	dW S |jd	krKt
t|jtttt| dd
| }
W n tyc   t|jt|j|jdw t|jt|j|
d)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_coder?   r@   )r   httpx_clientrequestrB   typingcastr   r   jsonr	   r   dictr?   r   r   r   textr    r&   r'   r(   r)   r*   r+   r,   	_response_data_response_jsonr!   r!   r"   list    sL   *

zRawDubbingClient.list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,   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   c             	   C   s  | j jjddi d|d|d|d|d|	d|
d	|d
|d|d|d|d|d|d|d|d|i |dur@d|ini |durJd|ini |durTd|ini |dur^d|ini |tdd}z>d|j  krrdk rn ntttt|	 d}t
||dW S |jdkrtt|jtttt|	 dd|	 }W n ty   t|jt|j|jd w t|jt|j|d )!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.

        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
        r/   POSTrT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   NrP   rQ   rR   rS   Tr3   r<   filesr,   omitforce_multipartr5   r6   r7   r:   r=   r>   rA   )r   rC   rD   OMITrB   rE   rF   r   r   rG   r	   r   rH   r?   r   r   r   rI   r    rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   r,   rK   rL   rM   r!   r!   r"   createq   s   b	


zRawDubbingClient.creater,   
dubbing_idc             	   C      | j jjdt| d|d}z>d|j  krdk r0n ntttt|	 d}t
||dW S |jdkrHtt|jtttt|	 dd	|	 }W n ty`   t|jt|j|jd
w t|jt|j|d
)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/r0   r3   r,   r5   r6   r7   r:   r=   r>   rA   )r   rC   rD   r
   rB   rE   rF   r   r   rG   r	   r   rH   r?   r   r   r   rI   r    rm   r,   rK   rL   rM   r!   r!   r"   get  >   

zRawDubbingClient.getc             	   C   rn   )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
        ro   DELETErp   r5   r6   r7   r:   r=   r>   rA   )r   rC   rD   r
   rB   rE   rF   r   r   rG   r	   r   rH   r?   r   r   r   rI   rq   r!   r!   r"   delete>  rs   zRawDubbingClient.delete)__name__
__module____qualname__r   r#   rE   Optionalstrintr   r   Literalr   r   r	   r   rN   ri   r   Fileboolr   floatr   rk   r   rr   r   ru   r!   r!   r!   r"   r          	

T



	

 
3r   c                .   @   r   ).AsyncRawDubbingClientr   c                C   r   r   r   r   r!   r!   r"   r#   r  r$   zAsyncRawDubbingClient.__init__Nr%   r&   r'   r(   r)   r*   r-   r+   r,   r.   c             
      s   | j jjdd||||||d|dI dH }z>d|j  kr"dk r7n ntttt| d}	t	||	d	W S |jd
krOt
t|jtttt| dd| }
W n tyg   t|jt|j|jdw t|jt|j|
d)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
        r/   r0   r1   r2   Nr5   r6   r7   r:   r=   r>   rA   )r   rC   rD   rB   rE   rF   r   r   rG   r   r   rH   r?   r   r   r   rI   rJ   r!   r!   r"   rN   u  sN   *

zAsyncRawDubbingClient.listrO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   c             	      s  | j jjddi d|d|d|d|d|	d|
d	|d
|d|d|d|d|d|d|d|d|i |durAd|ini |durKd|ini |durUd|ini |dur_d|ini |tddI dH }z>d|j  krvdk rn ntttt|	 d}t
||dW S |jdkrtt|jtttt|	 dd|	 }W n ty   t|jt|j|jd w t|jt|j|d )!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.

        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
        r/   rd   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   NrP   rQ   rR   rS   Tre   r5   r6   r7   r:   r=   r>   rA   )r   rC   rD   ri   rB   rE   rF   r   r   rG   r   r   rH   r?   r   r   r   rI   rj   r!   r!   r"   rk     s   b	


zAsyncRawDubbingClient.createrl   rm   c             	         | j jjdt| d|dI dH }z>d|j  krdk r4n ntttt|	 d}t
||dW S |jd	krLtt|jtttt|	 dd
|	 }W n tyd   t|jt|j|jdw t|jt|j|d)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
        ro   r0   rp   Nr5   r6   r7   r:   r=   r>   rA   )r   rC   rD   r
   rB   rE   rF   r   r   rG   r   r   rH   r?   r   r   r   rI   rq   r!   r!   r"   rr   a  @   

zAsyncRawDubbingClient.getc             	      r   )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
        ro   rt   rp   Nr5   r6   r7   r:   r=   r>   rA   )r   rC   rD   r
   rB   rE   rF   r   r   rG   r   r   rH   r?   r   r   r   rI   rq   r!   r!   r"   ru     r   zAsyncRawDubbingClient.delete)rv   rw   rx   r   r#   rE   ry   rz   r{   r   r   r|   r   r   r   r   rN   ri   r   r}   r~   r   r   r   rk   r   rr   r   ru   r!   r!   r!   r"   r   q  r   r   ),rE   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   rF   Anyri   r   r   r!   r!   r!   r"   <module>   s0     W