o
    lWipI                     @   s   d dl 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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   )AsyncClientWrapperSyncClientWrapper)RequestOptions)DeleteHistoryItemResponse)GetSpeechHistoryResponse)SpeechHistoryItemResponse   )AsyncRawHistoryClientRawHistoryClient)HistoryListRequestSortDirection)HistoryListRequestSource.c                   @   \  e Zd ZdefddZedefddZddd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
 dej	e
 dej	e dej	e dej	e dej	e defddZdddedej	e defddZdddedej	e defddZdddedej	e deje fddZedddeje dej	e dej	e deje fd d!ZdS )"HistoryClientclient_wrapperc                C      t |d| _d S N)r   )r   _raw_clientselfr    r   ]/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/history/client.py__init__      zHistoryClient.__init__returnc                 C      | j S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawHistoryClient
        r   r   r   r   r   with_raw_response      	zHistoryClient.with_raw_responseN
	page_sizestart_after_history_item_idvoice_idmodel_iddate_before_unixdate_after_unixsort_directionsearchsourcerequest_optionsr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   c       
         C   s&   | j j|||||||||	|
d
}|jS )a~  
        Returns a list of your generated audio.

        Parameters
        ----------
        page_size : typing.Optional[int]
            How many history items to return at maximum. Can not exceed 1000, defaults to 100.

        start_after_history_item_id : typing.Optional[str]
            After which ID to start fetching, use this parameter to paginate across a large collection of history items. In case this parameter is not provided history items will be fetched starting from the most recently created one ordered descending by their creation date.

        voice_id : typing.Optional[str]
            ID of the voice to be filtered for. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.

        model_id : typing.Optional[str]
            Search term used for filtering history items. If provided, source becomes required.

        date_before_unix : typing.Optional[int]
            Unix timestamp to filter history items before this date (exclusive).

        date_after_unix : typing.Optional[int]
            Unix timestamp to filter history items after this date (inclusive).

        sort_direction : typing.Optional[HistoryListRequestSortDirection]
            Sort direction for the results.

        search : typing.Optional[str]
            search term used for filtering

        source : typing.Optional[HistoryListRequestSource]
            Source of the generated history item

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

        Returns
        -------
        GetSpeechHistoryResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.history.list(
            page_size=1,
            start_after_history_item_id="start_after_history_item_id",
            voice_id="voice_id",
            model_id="model_id",
            date_before_unix=1,
            date_after_unix=1,
            sort_direction="asc",
            search="search",
            source="TTS",
        )
        r    r   listdatar   r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   	_responser   r   r   r,   !   s   IzHistoryClient.listr*   history_item_idc                C      | j j||d}|jS )a  
        Retrieves a history item.

        Parameters
        ----------
        history_item_id : str
            ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items.

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

        Returns
        -------
        SpeechHistoryItemResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.history.get(
            history_item_id="VW7YKqPnjY4h39yTbx2L",
        )
        r0   r   getr-   r   r1   r*   r/   r   r   r   r4   x      zHistoryClient.getc                C   r2   )a  
        Delete a history item by its ID

        Parameters
        ----------
        history_item_id : str
            ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items.

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

        Returns
        -------
        DeleteHistoryItemResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.history.delete(
            history_item_id="VW7YKqPnjY4h39yTbx2L",
        )
        r0   r   deleter-   r5   r   r   r   r8      r6   zHistoryClient.deletec                c   sD    | j j||d}|jE dH  W d   dS 1 sw   Y  dS )aS  
        Returns the audio of an history item.

        Parameters
        ----------
        history_item_id : str
            ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            The audio file of the history item.

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.history.get_audio(
            history_item_id="history_item_id",
        )
        r0   Nr   	get_audior-   )r   r1   r*   rr   r   r   r:      s   "zHistoryClient.get_audiooutput_formatr*   history_item_idsr=   c                c   sF    | j j|||d}|jE dH  W d   dS 1 sw   Y  dS )a  
        Download one or more history items. If one history item ID is provided, we will return a single audio file. If more than one history item IDs are provided, we will provide the history items packed into a .zip file.

        Parameters
        ----------
        history_item_ids : typing.Sequence[str]
            A list of history items to download, you can get IDs of history items and other metadata using the GET https://api.elevenlabs.io/v1/history endpoint.

        output_format : typing.Optional[str]
            Output format to transcode the audio file, can be wav or default.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            The requested audio file, or a zip file containing multiple audio files when multiple history items are requested.

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.history.download(
            history_item_ids=["history_item_ids", "history_item_ids"],
        )
        r>   r=   r*   Nr   downloadr-   )r   r>   r=   r*   r;   r   r   r   rA      s   %"zHistoryClient.download)__name__
__module____qualname__r   r   propertyr   r   typingOptionalintstrr   r   r   r   r,   r   r4   r   r8   Iteratorbytesr:   OMITSequencerA   r   r   r   r   r      s    	

X
"
"
%r   c                   @   r   )"AsyncHistoryClientr   c                C   r   r   )r
   r   r   r   r   r   r     r   zAsyncHistoryClient.__init__r   c                 C   r   )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawHistoryClient
        r   r   r   r   r   r   
  r   z$AsyncHistoryClient.with_raw_responseNr    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   c       
            s.   | j j|||||||||	|
d
I dH }|jS )a	  
        Returns a list of your generated audio.

        Parameters
        ----------
        page_size : typing.Optional[int]
            How many history items to return at maximum. Can not exceed 1000, defaults to 100.

        start_after_history_item_id : typing.Optional[str]
            After which ID to start fetching, use this parameter to paginate across a large collection of history items. In case this parameter is not provided history items will be fetched starting from the most recently created one ordered descending by their creation date.

        voice_id : typing.Optional[str]
            ID of the voice to be filtered for. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.

        model_id : typing.Optional[str]
            Search term used for filtering history items. If provided, source becomes required.

        date_before_unix : typing.Optional[int]
            Unix timestamp to filter history items before this date (exclusive).

        date_after_unix : typing.Optional[int]
            Unix timestamp to filter history items after this date (inclusive).

        sort_direction : typing.Optional[HistoryListRequestSortDirection]
            Sort direction for the results.

        search : typing.Optional[str]
            search term used for filtering

        source : typing.Optional[HistoryListRequestSource]
            Source of the generated history item

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

        Returns
        -------
        GetSpeechHistoryResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.history.list(
                page_size=1,
                start_after_history_item_id="start_after_history_item_id",
                voice_id="voice_id",
                model_id="model_id",
                date_before_unix=1,
                date_after_unix=1,
                sort_direction="asc",
                search="search",
                source="TTS",
            )


        asyncio.run(main())
        r    Nr+   r.   r   r   r   r,     s   QzAsyncHistoryClient.listr0   r1   c                      | j j||dI dH }|jS )aK  
        Retrieves a history item.

        Parameters
        ----------
        history_item_id : str
            ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items.

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

        Returns
        -------
        SpeechHistoryItemResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.history.get(
                history_item_id="VW7YKqPnjY4h39yTbx2L",
            )


        asyncio.run(main())
        r0   Nr3   r5   r   r   r   r4   t     &zAsyncHistoryClient.getc                   rO   )aT  
        Delete a history item by its ID

        Parameters
        ----------
        history_item_id : str
            ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items.

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

        Returns
        -------
        DeleteHistoryItemResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.history.delete(
                history_item_id="VW7YKqPnjY4h39yTbx2L",
            )


        asyncio.run(main())
        r0   Nr7   r5   r   r   r   r8     rP   zAsyncHistoryClient.deletec             	   C  sh   | j j||d4 I dH }|j2 z	3 dH W }|V  q6 W d  I dH  dS 1 I dH s-w   Y  dS )a  
        Returns the audio of an history item.

        Parameters
        ----------
        history_item_id : str
            ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            The audio file of the history item.

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.history.get_audio(
                history_item_id="history_item_id",
            )


        asyncio.run(main())
        r0   Nr9   )r   r1   r*   r;   _chunkr   r   r   r:     s   &.zAsyncHistoryClient.get_audior<   r>   r=   c             	   C  sj   | j j|||d4 I dH }|j2 z	3 dH W }|V  q6 W d  I dH  dS 1 I dH s.w   Y  dS )am  
        Download one or more history items. If one history item ID is provided, we will return a single audio file. If more than one history item IDs are provided, we will provide the history items packed into a .zip file.

        Parameters
        ----------
        history_item_ids : typing.Sequence[str]
            A list of history items to download, you can get IDs of history items and other metadata using the GET https://api.elevenlabs.io/v1/history endpoint.

        output_format : typing.Optional[str]
            Output format to transcode the audio file, can be wav or default.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            The requested audio file, or a zip file containing multiple audio files when multiple history items are requested.

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.history.download(
                history_item_ids=["history_item_ids", "history_item_ids"],
            )


        asyncio.run(main())
        r?   Nr@   )r   r>   r=   r*   r;   rQ   r   r   r   rA     s   -.zAsyncHistoryClient.download)rB   rC   rD   r   r   rE   r
   r   rF   rG   rH   rI   r   r   r   r   r,   r   r4   r   r8   AsyncIteratorrK   r:   rL   rM   rA   r   r   r   r   rN     s    	

`
*
*
.rN   )rF   core.client_wrapperr   r   core.request_optionsr   "types.delete_history_item_responser   !types.get_speech_history_responser   "types.speech_history_item_responser   
raw_clientr
   r   )types.history_list_request_sort_directionr   !types.history_list_request_sourcer   castAnyrL   r   rN   r   r   r   r   <module>   s    u