
    b6iR                        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 ddlmZ ddlmZ  ej4                  ej6                  d      Z G d d      Z G d d      Zy)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)UnprocessableEntityError)HttpValidationError)$ProjectSnapshotExtendedResponseModel)ProjectSnapshotsResponse.c                      e Zd ZdefdZdddedej                  e   de	e
   fdZddded	edej                  e   de	e   fd
Zej                  eddded	edej                  e   dej                  e   dej$                  e	ej$                  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)RawSnapshotsClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     z/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/studio/projects/snapshots/raw_client.py__init__zRawSnapshotsClient.__init__   
    -    Nrequest_options
project_idr   returnc                   | j                   j                  j                  dt        |       dd|      }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |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)a  
        Retrieves a list of snapshots for a Studio project.

        Parameters
        ----------
        project_id : str
            The ID of the Studio project.

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

        Returns
        -------
        HttpResponse[ProjectSnapshotsResponse]
            Successful Response
        v1/studio/projects/
/snapshotsGETmethodr      ,  type_object_responsedata  headersbodystatus_coder2   r3   )r   httpx_clientrequestr
   r5   typingcastr   r   jsonr	   r   dictr2   r   r   r   textr   r    r   	_response_data_response_jsons         r   listzRawSnapshotsClient.list   sD   & ((55==!"2:">!?zJ+ > 
	
	ti++1c1,"6 ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AD2 A4D2 2?E1project_snapshot_idc                   | j                   j                  j                  dt        |       dt        |       d|      }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |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)a  
        Returns the project snapshot.

        Parameters
        ----------
        project_id : str
            The ID of the Studio project.

        project_snapshot_id : str
            The ID of the Studio project snapshot.

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

        Returns
        -------
        HttpResponse[ProjectSnapshotExtendedResponseModel]
            Successful Response
        r#   /snapshots/r%   r&   r(   r)   r*   r-   r0   r1   r4   )r   r6   r7   r
   r5   r8   r9   r   r   r:   r	   r   r;   r2   r   r   r   r<   r   r    rB   r   r>   r?   r@   s          r   getzRawSnapshotsClient.getL   sP   , ((55==!"2:">!?{K[\oKpJqr+ > 
	
	ti++1c18"B ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AD= A4D= =?E<convert_to_mpegr   rH   c             #   .  K   | j                   j                  j                  dt        |       dt        |       ddd|iddit              5 d	t
        t        j                  t              ffd
} |        ddd       y# 1 sw Y   yxY ww)a0  
        Stream the audio from a Studio project snapshot.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        project_snapshot_id : str
            The ID of the Studio project snapshot.

        convert_to_mpeg : typing.Optional[bool]
            Whether to convert the audio to mpeg format.

        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
        r#   rD   /streamPOSTrH   content-typeapplication/jsonr'   r:   r2   r   omitr!   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)Nr(   r)   
chunk_size   c              3       K   | ]  }|  y wr    .0_chunks     r   	<genexpr>z=RawSnapshotsClient.stream.<locals>._stream.<locals>.<genexpr>        5xf5x   rQ   r-   r0   r*   r1   r4   r5   rF   r	   
iter_bytesreadr   r;   r2   r8   r9   r   r   r:   r   r   r<   _chunk_sizer@   r>   r   s     r   _streamz*RawSnapshotsClient.stream.<locals>._stream   #   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    AD BD ?EN)	r   r6   streamr
   OMITr	   r8   Iteratorbytesr   r    rB   rH   r   ra   r>   s       ` @r   rd   zRawSnapshotsClient.stream   s     > !!..55!"2:">!?{K[\oKpJqqxy!?  2 , 6 
 '	 x\&//%*@A x4 )OO'	 '	 '	s   AB/B	 	B	BBc             #     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 a compressed archive of the Studio project's audio.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        project_snapshot_id : str
            The ID of the Studio project snapshot.

        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]]]
            Streaming archive data
        r#   rD   /archiverK   r&   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)Nr(   r)   rQ   rR   c              3       K   | ]  }|  y wr   rT   rU   s     r   rX   zERawSnapshotsClient.stream_archive.<locals>._stream.<locals>.<genexpr>   rY   rZ   r[   r-   r0   r*   r1   r4   r\   r_   s     r   ra   z2RawSnapshotsClient.stream_archive.<locals>._stream   rb   rc   N)r   r6   rd   r
   r	   r8   rf   rg   r   r    rB   r   ra   r>   s      ` @r   stream_archivez!RawSnapshotsClient.stream_archive   s     . !!..55!"2:">!?{K[\oKpJqqyz+ 6 
  	 x\&//%*@A x4 )OA 	  	  	s   AB
/A>5	B
>BB
)__name__
__module____qualname__r   r   strr8   Optionalr   r	   r   rA   r   rF   
contextlibcontextmanagerre   boolrf   rg   rd   rn   rT   r   r   r   r      sj   .*; . VZ0p0p39??>3R0p	.	/0pf pt3p3p473pMS__]kMl3p	:	;3pj  26;?EE !E
  .E  8E 
fooe&<=	>E EN os66476MS__]kMl6	fooe&<=	>6 6r   r   c                      e Zd ZdefdZdddedej                  e   de	e
   fdZddded	edej                  e   de	e   fd
Zej                  eddded	edej                  e   dej                  e   dej$                  e	ej$                  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)AsyncRawSnapshotsClientr   c                    || _         y r   r   r   s     r   r   z AsyncRawSnapshotsClient.__init__  r   r   Nr   r    r   r!   c                  K   | j                   j                  j                  dt        |       dd|       d{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||	      S |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)a  
        Retrieves a list of snapshots for a Studio project.

        Parameters
        ----------
        project_id : str
            The ID of the Studio project.

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

        Returns
        -------
        AsyncHttpResponse[ProjectSnapshotsResponse]
            Successful Response
        r#   r$   r%   r&   Nr(   r)   r*   r-   r0   r1   r4   )r   r6   r7   r
   r5   r8   r9   r   r   r:   r   r   r;   r2   r   r   r   r<   r=   s         r   rA   zAsyncRawSnapshotsClient.list  sR    & ..;;CC!"2:">!?zJ+ D 
 
	
	ti++1c1,"6 ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	ts5   9FD<FAD? FA4D? ,F??E>>FrB   c                  K   | j                   j                  j                  dt        |       dt        |       d|       d{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||	      S |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)a  
        Returns the project snapshot.

        Parameters
        ----------
        project_id : str
            The ID of the Studio project.

        project_snapshot_id : str
            The ID of the Studio project snapshot.

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

        Returns
        -------
        AsyncHttpResponse[ProjectSnapshotExtendedResponseModel]
            Successful Response
        r#   rD   r%   r&   Nr(   r)   r*   r-   r0   r1   r4   )r   r6   r7   r
   r5   r8   r9   r   r   r:   r   r   r;   r2   r   r   r   r<   rE   s          r   rF   zAsyncRawSnapshotsClient.get9  s^    , ..;;CC!"2:">!?{K[\oKpJqr+ D 
 
	
	ti++1c18"B ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	ts8   AFEFAE
 'F(A4E
 ,F
?F		FrG   rH   c               ~  K   | j                   j                  j                  dt        |       dt        |       ddd|iddit              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?  
        Stream the audio from a Studio project snapshot.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        project_snapshot_id : str
            The ID of the Studio project snapshot.

        convert_to_mpeg : typing.Optional[bool]
            Whether to convert the audio to mpeg format.

        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#   rD   rJ   rK   rH   rL   rM   rN   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)   rQ   rR   c                2   K   | 3 d {   }| 7 
6 y wr   rT   rU   s     r   rX   zBAsyncRawSnapshotsClient.stream.<locals>._stream.<locals>.<genexpr>       !k!k6&!k!k   r[   r-   r0   r*   r1   r4   r5   rF   r   aiter_bytesareadr   r;   r2   r8   r9   r   r   r:   r   r   r<   r_   s     r   ra   z/AsyncRawSnapshotsClient.stream.<locals>._stream  1    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 <   EAD ED *D+A8D #+ED ?EE)	r   r6   rd   r
   re   r   r8   AsyncIteratorrg   rh   s       ` @r   rd   zAsyncRawSnapshotsClient.streamn  s     > ''44;;!"2:">!?{K[\oKpJqqxy!?  2 , < 
 (	" (	" x#4V5I5I%5P#Q x6  	/!Q(	" (	" (	"P "Q(	" (	" (	" (	"sZ   AB=B"B=0B(	B$
B(B=B&B=$B(&B=(B:.B1/B:6B=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 a compressed archive of the Studio project's audio.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        project_snapshot_id : str
            The ID of the Studio project snapshot.

        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]]]
            Streaming archive data
        r#   rD   rj   rK   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)   rQ   rR   c                2   K   | 3 d {   }| 7 
6 y wr   rT   rU   s     r   rX   zJAsyncRawSnapshotsClient.stream_archive.<locals>._stream.<locals>.<genexpr>  r   r   r[   r-   r0   r*   r1   r4   r   r_   s     r   ra   z7AsyncRawSnapshotsClient.stream_archive.<locals>._stream  r   r   )r   r6   rd   r
   r   r8   r   rg   rm   s      ` @r   rn   z&AsyncRawSnapshotsClient.stream_archive  s     . ''44;;!"2:">!?{K[\oKpJqqyz+ < 
 !	" !	" 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)ro   rp   rq   r   r   rr   r8   rs   r   r   r   rA   r   rF   rt   asynccontextmanagerre   rv   r   rg   rd   rn   rT   r   r   rx   rx     st   .*< . VZ0p0p39??>3R0p	3	40pf pt3p3p473pMS__]kMl3p	?	@3pj ## 26;?F"F" !F"
  .F"  8F" 
		/0D0DU0KL	MF" $F"P ##os7"7"477"MS__]kMl7"			/0D0DU0KL	M7" $7"r   rx   )rt   r8   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   .types.project_snapshot_extended_response_modelr    types.project_snapshots_responser   r9   Anyre   r   rx   rT   r   r   <module>r      s_      ( ' I B 6 3 8 J ? c I v{{6::s#j jZl" l"r   