o
    lWiN                     @   s   d dl Z d dl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 G dd dZG dd dZdS )    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)UnprocessableEntityError)HttpValidationErrorc                   @   V   e Zd ZdefddZejdddededej	e
 d	ejeeje   fd
dZdS )RawAudioClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   n/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/voices/samples/audio/raw_client.py__init__      
zRawAudioClient.__init__Nrequest_optionsvoice_id	sample_idr   returnc                #   sx    | j jjdt| dt| ddd dttjt  f fdd}| V  W d	   d	S 1 s5w   Y  d	S )
a  
        Returns the audio corresponding to a sample attached to a voice.

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

        sample_id : str
            ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint 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.

        Returns
        -------
        typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
            Successful Response
        
v1/voices/	/samples//audioGETmethodr   r   c               	      s   zKd j   krdk r*n nd urddnd} t dd  j| dD dW S     j d	krFtt jt	t
tt
  d
d  }W n ty^   t j t j jdw t j t j|d)N   ,  
chunk_size   c                 s   s    | ]}|V  qd S r   r   .0_chunkr   r   r   	<genexpr>7   s    z6RawAudioClient.get.<locals>._stream.<locals>.<genexpr>r(   responsedata  type_object_headersbodystatus_coder7   r8   )r:   getr   
iter_bytesreadr   dictr7   typingcastr   r   jsonr   r   text_chunk_size_response_json	_responser   r   r   _stream2   s2   

z#RawAudioClient.get.<locals>._streamN)r   httpx_clientstreamr	   r   r?   Iteratorbytesr   r   r   r   rH   r   rF   r   r;      s   
"zRawAudioClient.get)__name__
__module____qualname__r   r   
contextlibcontextmanagerstrr?   Optionalr
   rK   r   rL   r;   r   r   r   r   r          r   c                   @   r   )AsyncRawAudioClientr   c                C   r   r   r   r   r   r   r   r   P   r   zAsyncRawAudioClient.__init__Nr   r   r   r   r   c             	     s   | j jjdt| dt| ddd4 I dH " dttjt  f fdd	}| I dH V  W d  I dH  dS 1 I dH sBw   Y  dS )
a-  
        Returns the audio corresponding to a sample attached to a voice.

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

        sample_id : str
            ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint 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.

        Returns
        -------
        typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
            Successful Response
        r    r!   r"   r#   r$   Nr   c               	      s   zNd j   krdk r+n nd urddnd} t dd  j| d2 dW S   I d H   j d	krJtt jt	t
tt
  d
d  }W n tyb   t j t j jdw t j t j|d)Nr&   r'   r(   r)   c                 S  s   | z	3 d H W }|V  q6 d S r   r   r*   r   r   r   r-   v   s    z;AsyncRawAudioClient.get.<locals>._stream.<locals>.<genexpr>r.   r/   r2   r3   r6   r9   )r:   r;   r   aiter_bytesareadr   r>   r7   r?   r@   r   r   rA   r   r   rB   rC   rF   r   r   rH   p   s6   

z(AsyncRawAudioClient.get.<locals>._stream)r   rI   rJ   r	   r   r?   AsyncIteratorrL   rM   r   rF   r   r;   S   s   .zAsyncRawAudioClient.get)rN   rO   rP   r   r   rQ   asynccontextmanagerrS   r?   rT   r
   rY   r   rL   r;   r   r   r   r   rV   O   rU   rV   )rQ   r?   json.decoderr   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.http_validation_errorr   r   rV   r   r   r   r   <module>   s   >