
    b6iN                         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      Z G d d      Zy)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)UnprocessableEntityError)HttpValidationErrorc                       e Zd ZdefdZej                  dddededej                  e
   dej                  eej                  e         fd	       Zy)
RawAudioClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     u/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/voices/samples/audio/raw_client.py__init__zRawAudioClient.__init__   
    -    Nrequest_optionsvoice_id	sample_idr   returnc             #     K   | j                   j                  j                  dt        |       dt        |       dd      5 dt        t
        j                  t              ffd} |        ddd       y# 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
            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                     	 dj                   cxk  rdk  r=n n:j                  dd      nd} t        d j                  |       D              S j	                          j                   dk(  rUt        t        j                        t        j                  t        t        t        j                         	            
      j                         }t        j                   t        j                        |      # t        $ r6 t        j                   t        j                        j                        w xY w)N   ,  
chunk_size   c              3       K   | ]  }|  y wr    .0_chunks     r   	<genexpr>z6RawAudioClient.get.<locals>._stream.<locals>.<genexpr>7   s     5xf5xs   r+   responsedata  type_object_headersbodystatus_coder<   r=   )r?   getr	   
iter_bytesreadr   dictr<   typingcastr   r   jsonr   r   text_chunk_size_response_json	_responser   s     r   _streamz#RawAudioClient.get.<locals>._stream2   s#   i339c9Q`Qlo&9&9,&Mrv+%.5x9K_K_kvK_Kw5x   NN$ ,,36$():):$;!' 3 .*=,5NN,<!""	 	 &/^^%5N
 9+@+@$yO`O`Jahvww	 ' "$-$9$94	HYHYCZajaoao s   AD BD ?EN)r   httpx_clientstreamr
   r	   rD   Iteratorbytesr   r   r   r   rL   rK   s      ` @r   r@   zRawAudioClient.get   s     . !!..55)(34I>Ny>Y=ZZ`a+ 6 
  	 x\&//%*@A x4 )OA 	  	  	s   AB
/A>5	B
>BB
)__name__
__module____qualname__r   r   
contextlibcontextmanagerstrrD   Optionalr   rO   r	   rP   r@   r.   r   r   r   r      sm    .*; . cg66(+6AGQ_A`6	fooe&<=	>6 6r   r   c                       e Zd ZdefdZej                  dddededej                  e
   dej                  eej                  e         fd	       Zy)
AsyncRawAudioClientr   c                    || _         y r   r   r   s     r   r   zAsyncRawAudioClient.__init__P   r   r   Nr   r   r   r   r    c               h  K   | j                   j                  j                  dt        |       dt        |       dd      4 d{   dt        t
        j                  t              ffd} |        d{    ddd      d{    y7 L7 7 	# 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
            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                    K   	 dj                   cxk  rdk  r=n n:j                  dd      nd} t        d j                  |       2              S j	                          d {    j                   dk(  rUt        t        j                        t        j                  t        t        t        j                         	            
      j                         }t        j                   t        j                        |      7 # t        $ r6 t        j                   t        j                        j                        w xY ww)Nr)   r*   r+   r,   c                2   K   | 3 d {   }| 7 
6 y wr   r.   r/   s     r   r2   z;AsyncRawAudioClient.get.<locals>._stream.<locals>.<genexpr>v   s     !k!k6&!k!ks   r3   r4   r7   r8   r;   r>   )r?   r@   r   aiter_bytesareadr   rC   r<   rD   rE   r   r   rF   r   r   rG   rH   s     r   rL   z(AsyncRawAudioClient.get.<locals>._streamp   s1    i339c9Q`Qlo&9&9,&Mrv0%.!kY=R=R^i=R=j!k   $//+++ ,,36$():):$;!' 3 .*=,5NN,<!""	 	 &/^^%5N
 9+@+@$yO`O`Jahvww# , ' "$-$9$94	HYHYCZajaoao s<   EAD ED *D+A8D #+ED ?EE)r   rM   rN   r
   r   rD   AsyncIteratorrP   rQ   s      ` @r   r@   zAsyncRawAudioClient.getS   s     . ''44;;)(34I>Ny>Y=ZZ`a+ < 
 !	" !	" x#4V5I5I%5P#Q x6  	/!C!	" !	" !	"B "C!	" !	" !	" !	"sZ   AB2
BB20B>B?BB2BB2BB2B/#B&$B/+B2)rR   rS   rT   r   r   rU   asynccontextmanagerrW   rD   rX   r   ra   r   rP   r@   r.   r   r   rZ   rZ   O   sr    .*< . ##cg7"7"(+7"AGQ_A`7"			/0D0DU0KL	M7" $7"r   rZ   )rU   rD   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   rZ   r.   r   r   <module>rl      s=      ( ' I B 6 3 8 J ?; ;|<" <"r   