o
    "i4                     @   s   d dl Z 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 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 zd dlmZ W n ey[   d dlZY nw e e jdZG dd dZG dd dZ dS )    N)JSONDecodeError   )core)ApiError)AsyncClientWrapperSyncClientWrapper)jsonable_encoder)remove_none_from_dict)RequestOptions)UnprocessableEntityError)%AudioNativeCreateProjectResponseModel)HttpValidationError.c                   @      e Zd ZdefddZddddddddddddd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deje deje defddZdS )AudioNativeClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   b/var/www/html/voicebot/backend/venv/lib/python3.10/site-packages/elevenlabs/audio_native/client.py__init__      
zAudioNativeClient.__init__Nimageauthortitlesmall
text_colorbackground_colorsessionizationvoice_idmodel_idauto_convertrequest_optionsnamer   r   r   r   r    r!   r"   r#   r$   filer%   r&   returnc                C   s  | j jjdtj| j   ddt|dur|dnd|du s(|ddu r:tt	|||||||||	|
|dni tt	|||||||||	|
|dtt	|di t
t	d|itt	i | j  |durq|d	i ni |dur|d
dur|d
ndd|dur|dndd	}d|j  krdk rn ntt| S |jdkrttt| z| }W n ty   t|j|jdw t|j|d)a]  
        Creates AudioNative enabled project, optionally starts conversion and returns project id and embeddable html snippet.

        Parameters:
            - name: str. Project name.

            - image: typing.Optional[str]. Image URL used in the player. If not provided, default image set in the Player settings is used.

            - author: typing.Optional[str]. Author used in the player and inserted at the start of the uploaded article. If not provided, the default author set in the Player settings is used.

            - title: typing.Optional[str]. Title used in the player and inserted at the top of the uploaded article. If not provided, the default title set in the Player settings is used.

            - small: typing.Optional[bool]. Whether to use small player or not. If not provided, default value set in the Player settings is used.

            - text_color: typing.Optional[str]. Text color used in the player. If not provided, default text color set in the Player settings is used.

            - background_color: typing.Optional[str]. Background color used in the player. If not provided, default background color set in the Player settings is used.

            - sessionization: typing.Optional[int]. Specifies for how many minutes to persist the session across page reloads. If not provided, default sessionization set in the Player settings is used.

            - voice_id: typing.Optional[str]. Voice ID used to voice the content. If not provided, default voice ID set in the Player settings is used.

            - model_id: typing.Optional[str]. TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used.

            - file: core.File. See core.File for more documentation

            - auto_convert: typing.Optional[bool]. Whether to auto convert the project to audio or not.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from elevenlabs.client import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.audio_native.create()
        POST/v1/audio-nativeNadditional_query_parametersadditional_body_parametersr'   r   r   r   r   r    r!   r"   r#   r$   r%   r(   additional_headerstimeout_in_seconds<   r   max_retriesparamsdatafilesheaderstimeoutretriesr3      ,    status_codebodyr   httpx_clientrequesturllibparseurljoinget_base_urlr   getr	   r   !convert_file_dict_to_httpx_tuplesget_headersr?   pydanticparse_obj_asr   jsonr   r   r   r   textr   r'   r   r   r   r   r    r!   r"   r#   r$   r(   r%   r&   	_response_response_jsonr   r   r   create   s   6	
;
zAudioNativeClient.create)__name__
__module____qualname__r   r   strtypingOptionalboolintr   Filer
   r   rR   r   r   r   r   r      T    	
r   c                   @   r   )AsyncAudioNativeClientr   c                C   r   r   r   r   r   r   r   r      r   zAsyncAudioNativeClient.__init__Nr   r'   r   r   r   r   r    r!   r"   r#   r$   r(   r%   r&   r)   c                   s  | j jjdtj| j   ddt|dur|dnd|du s)|ddu r;tt	|||||||||	|
|dni tt	|||||||||	|
|dtt	|di t
t	d|itt	i | j  |durr|d	i ni |dur|d
dur|d
ndd|dur|dndd	I dH }d|j  krdk rn ntt| S |jdkrttt| z| }W n ty   t|j|jdw t|j|d)am  
        Creates AudioNative enabled project, optionally starts conversion and returns project id and embeddable html snippet.

        Parameters:
            - name: str. Project name.

            - image: typing.Optional[str]. Image URL used in the player. If not provided, default image set in the Player settings is used.

            - author: typing.Optional[str]. Author used in the player and inserted at the start of the uploaded article. If not provided, the default author set in the Player settings is used.

            - title: typing.Optional[str]. Title used in the player and inserted at the top of the uploaded article. If not provided, the default title set in the Player settings is used.

            - small: typing.Optional[bool]. Whether to use small player or not. If not provided, default value set in the Player settings is used.

            - text_color: typing.Optional[str]. Text color used in the player. If not provided, default text color set in the Player settings is used.

            - background_color: typing.Optional[str]. Background color used in the player. If not provided, default background color set in the Player settings is used.

            - sessionization: typing.Optional[int]. Specifies for how many minutes to persist the session across page reloads. If not provided, default sessionization set in the Player settings is used.

            - voice_id: typing.Optional[str]. Voice ID used to voice the content. If not provided, default voice ID set in the Player settings is used.

            - model_id: typing.Optional[str]. TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used.

            - file: core.File. See core.File for more documentation

            - auto_convert: typing.Optional[bool]. Whether to auto convert the project to audio or not.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from elevenlabs.client import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )
        await client.audio_native.create()
        r*   r+   r,   Nr-   r.   r/   r(   r0   r1   r2   r   r3   r4   r;   r<   r=   r>   rA   rO   r   r   r   rR      s   6	
;
zAsyncAudioNativeClient.create)rS   rT   rU   r   r   rV   rW   rX   rY   rZ   r   r[   r
   r   rR   r   r   r   r   r]      r\   r]   )!rW   urllib.parserD   json.decoderr    r   core.api_errorr   core.client_wrapperr   r   core.jsonable_encoderr   core.remove_none_from_dictr	   core.request_optionsr
   !errors.unprocessable_entity_errorr   0types.audio_native_create_project_response_modelr   types.http_validation_errorr   pydantic.v1v1rK   ImportErrorcastAnyOMITr   r]   r   r   r   r   <module>   s*    