
    >|h)                         d dl m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
 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  G d d      Z G d d      Zy)   )SyncClientWrapper    N)RequestOptions)DeleteSampleResponseModel)jsonable_encoder)construct_type)UnprocessableEntityError)HttpValidationError)JSONDecodeError)ApiError)AsyncClientWrapperc            
           e Zd ZdefdZdddededej                  e   de	fd	Z
dddededej                  e   dej                  e   fd
Zy)SamplesClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     X/var/www/html/test/engine/venv/lib/python3.12/site-packages/elevenlabs/samples/client.py__init__zSamplesClient.__init__   
    -    Nrequest_optionsvoice_id	sample_idr   returnc          
      j   | j                   j                  j                  dt        |       dt        |       d|      }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  dk(  r@t        t        j                  t        t        t        |j                                           |j                         }t        |j                  |	      # t        $ r" t        |j                  |j                  	      w xY w)
aW  
        Removes a sample by its ID.

        Parameters
        ----------
        voice_id : str
            Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

        sample_id : str
            Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice.

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

        Returns
        -------
        DeleteSampleResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.samples.delete(
            voice_id="VOICE_ID",
            sample_id="SAMPLE_ID",
        )
        
v1/voices/	/samples/DELETEmethodr      ,  type_object_  status_codebodyr   httpx_clientrequestr   r-   typingcastr   r   jsonr	   r
   r   r   textr   r   r   r   	_response_response_jsons         r   deletezSamplesClient.delete   s   D ((55==)(34I>Ny>Y=Z[+ > 
	
	Si++1c1{{-"7 ) 0  $$+.KK+&"5$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   AD AD +D2c             #     K   | j                   j                  j                  dt        |       dt        |       dd|      5 }	 d|j                  cxk  rdk  r>n n;||j                  d	d
      nd
}|j                  |      D ]  }|  	 ddd       y|j                          |j                  dk(  r@t        t        j                  t        t        t        |j                                           |j                         }t        |j                  |      # t        $ r" t        |j                  |j                         w xY w# 1 sw Y   yxY ww)a  
        Returns the audio corresponding to a sample attached to a voice.

        Parameters
        ----------
        voice_id : str
            Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

        sample_id : str
            Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice.

        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.

        Yields
        ------
        typing.Iterator[bytes]
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.samples.get_audio(
            voice_id="VOICE_ID",
            sample_id="SAMPLE_ID",
        )
        r!   r"   /audioGETr$   r&   r'   N
chunk_size   r=   r+   r(   r,   )r   r0   streamr   r-   get
iter_bytesreadr	   r2   r3   r
   r   r4   r   r   r5   r   r   r   r   r7   _chunk_size_chunkr8   s           r   	get_audiozSamplesClient.get_audioS   sb    D !!..55)(34I>Ny>Y=ZZ`a+ 6 
 	S W)//5#5M\Mh/"5"5lD"InrK"+"6"6+"6"N %$%	S 	S  ((C/2/*&9(1(8  "+!1 y'<'<>RR # W9+@+@y~~VVW/	S 	Ss>   AEEA	D	EA/DE+E

EEE)__name__
__module____qualname__r   r   strr2   Optionalr   r   r9   IteratorbytesrG    r   r   r   r      s    .*; . dh=O=O(+=OAGQ_A`=O	"=O@ dh;S;S(+;SAGQ_A`;S		;Sr   r   c            
           e Zd ZdefdZdddededej                  e   de	fd	Z
dddededej                  e   dej                  e   fd
Zy)AsyncSamplesClientr   c                    || _         y r   r   r   s     r   r   zAsyncSamplesClient.__init__   r   r   Nr   r   r   r   r   c          
        K   | j                   j                  j                  dt        |       dt        |       d|       d{   }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  d	k(  r@t        t        j                  t        t        t        |j                                           |j                         }t        |j                  |
      7 # t        $ r" t        |j                  |j                  
      w xY ww)a  
        Removes a sample by its ID.

        Parameters
        ----------
        voice_id : str
            Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

        sample_id : str
            Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice.

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

        Returns
        -------
        DeleteSampleResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.samples.delete(
                voice_id="VOICE_ID",
                sample_id="SAMPLE_ID",
            )


        asyncio.run(main())
        r!   r"   r#   r$   Nr&   r'   r(   r+   r,   r/   r6   s         r   r9   zAsyncSamplesClient.delete   s(    T ..;;CC)(34I>Ny>Y=Z[+ D 
 
	
	Si++1c1{{-"7 ) 0  $$+.KK+&"5$-NN$4  '^^-N 9#8#8~NN7
2  	Sy'<'<9>>RR	Ss8   AEDEAD EAD :E+D>>Ec                 K   | j                   j                  j                  dt        |       dt        |       dd|      4 d{   }	 d|j                  cxk  rdk  r:n n7||j                  d	d
      nd
}|j                  |      2 3 d{   }| |j                          d{    |j                  dk(  r@t        t        j                  t        t        t        |j                                           |j                         }t        |j                  |      7 7 6 	 ddd      d{  7   y7 # t        $ r" t        |j                  |j                         w xY w# 1 d{  7  sw Y   yxY ww)a]  
        Returns the audio corresponding to a sample attached to a voice.

        Parameters
        ----------
        voice_id : str
            Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

        sample_id : str
            Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice.

        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.

        Yields
        ------
        typing.AsyncIterator[bytes]
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.samples.get_audio(
                voice_id="VOICE_ID",
                sample_id="SAMPLE_ID",
            )


        asyncio.run(main())
        r!   r"   r;   r<   r$   Nr&   r'   r=   r>   r?   r+   r(   r,   )r   r0   r@   r   r-   rA   aiter_bytesareadr	   r2   r3   r
   r   r4   r   r   r5   rD   s           r   rG   zAsyncSamplesClient.get_audio   s    T ''44;;)(34I>Ny>Y=ZZ`a+ < 
 	S 	S W)//5#5M\Mh/"5"5lD"InrK(1(=(=(=(U % %f$oo'''((C/2/*&9(1(8  "+!1 y'<'<>RR3	S%(U	S 	S 	S ( # W9+@+@y~~VVW/	S 	S 	Ss   AFD+	FE3A ED/D-D/E0E1A#EE3+F-D//E1F<D?=FE+E00E33F9E<:FF)rH   rI   rJ   r   r   rK   r2   rL   r   r   r9   AsyncIteratorrN   rG   rO   r   r   rQ   rQ      s    .*< . dhEOEO(+EOAGQ_A`EO	"EOP dhCSCS(+CSAGQ_A`CS			e	$CSr   rQ   )core.client_wrapperr   r2   core.request_optionsr   "types.delete_sample_response_modelr   core.jsonable_encoderr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr	   types.http_validation_errorr
   json.decoderr   core.api_errorr   r   r   rQ   rO   r   r   <module>ra      sE    4  1 J 4 6 H = ( % 4~S ~SBNS NSr   