o
    lWiR                     @   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 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)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)UnprocessableEntityError)HttpValidationError)$ProjectSnapshotExtendedResponseModel)ProjectSnapshotsResponse.c                   @      e Zd ZdefddZdddedeje de	e
 fd	d
Zdddededeje de	e fd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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 )RawSnapshotsClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   s/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/studio/projects/snapshots/raw_client.py__init__      
zRawSnapshotsClient.__init__Nrequest_options
project_idr   returnc             	   C   s   | j jjdt| dd|d}z>d|j  krdk r1n ntttt|	 d}t
||dW S |jd	krItt|jtttt|	 dd
|	 }W n tya   t|jt|j|jdw t|jt|j|d)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_coder0   r1   )r   httpx_clientrequestr	   r3   typingcastr   r   jsonr   r   dictr0   r   r   r   textr   r   r   	_response_data_response_jsonr   r   r   list   s>   

zRawSnapshotsClient.listproject_snapshot_idc             	   C   s   | j jjdt| dt| d|d}z>d|j  kr dk r5n ntttt|	 d}t
||dW S |jd	krMtt|jtttt|	 dd
|	 }W n tye   t|jt|j|jdw t|jt|j|d)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+   r.   r/   r2   )r   r4   r5   r	   r3   r6   r7   r   r   r8   r   r   r9   r0   r   r   r   r:   r   r   r@   r   r<   r=   r>   r   r   r   getL   s>   

zRawSnapshotsClient.getconvert_to_mpegr   rE   c                #   s    | j jjdt| dt| ddd|idditd d	ttjt  f fd
d}| V  W d   dS 1 s<w   Y  dS )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!   rA   /streamPOSTrE   content-typeapplication/jsonr%   r8   r0   r   omitr    c               	         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)Nr&   r'   
chunk_size   c                 s       | ]}|V  qd S r   r   .0_chunkr   r   r   	<genexpr>       z=RawSnapshotsClient.stream.<locals>._stream.<locals>.<genexpr>rM   r+   r.   r(   r/   r2   r3   rC   r   
iter_bytesreadr   r9   r0   r6   r7   r   r   r8   r   r   r:   _chunk_sizer>   r<   r   r   r   _stream   2   

z*RawSnapshotsClient.stream.<locals>._streamN)	r   r4   streamr	   OMITr   r6   Iteratorbytesr   r   r@   rE   r   r\   r   r[   r   r^      s   
"zRawSnapshotsClient.streamc                #   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 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!   rA   /archiverG   r$   r    c               	      rL   )Nr&   r'   rM   rN   c                 s   rO   r   r   rP   r   r   r   rS      rT   zERawSnapshotsClient.stream_archive.<locals>._stream.<locals>.<genexpr>rU   r+   r.   r(   r/   r2   rV   rY   r[   r   r   r\      r]   z2RawSnapshotsClient.stream_archive.<locals>._streamN)r   r4   r^   r	   r   r6   r`   ra   r   r   r@   r   r\   r   r[   r   stream_archive   s   
"z!RawSnapshotsClient.stream_archive)__name__
__module____qualname__r   r   strr6   Optionalr
   r   r   r?   r   rC   
contextlibcontextmanagerr_   boolr`   ra   r^   re   r   r   r   r   r      sZ    
3
5Gr   c                   @   r   )AsyncRawSnapshotsClientr   c                C   r   r   r   r   r   r   r   r     r   z AsyncRawSnapshotsClient.__init__Nr   r   r   r    c             	      s   | j jjdt| dd|dI dH }z>d|j  kr dk r5n ntttt|	 d}t
||d	W S |jd
krMtt|jtttt|	 dd|	 }W n tye   t|jt|j|jdw t|jt|j|d)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+   r.   r/   r2   )r   r4   r5   r	   r3   r6   r7   r   r   r8   r   r   r9   r0   r   r   r   r:   r;   r   r   r   r?     s@   

zAsyncRawSnapshotsClient.listr@   c             	      s   | j jjdt| dt| d|dI dH }z>d|j  kr$dk r9n ntttt|	 d}t
||d	W S |jd
krQtt|jtttt|	 dd|	 }W n tyi   t|jt|j|jdw t|jt|j|d)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!   rA   r#   r$   Nr&   r'   r(   r+   r.   r/   r2   )r   r4   r5   r	   r3   r6   r7   r   r   r8   r   r   r9   r0   r   r   r   r:   rB   r   r   r   rC   9  s@   

zAsyncRawSnapshotsClient.getrD   rE   c             	     s   | j jjdt| dt| ddd|iddit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 sIw   Y  d	S )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!   rA   rF   rG   rE   rH   rI   rJ   Nr    c               	         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'   rM   rN   c                 S     | z	3 d H W }|V  q6 d S r   r   rP   r   r   r   rS         zBAsyncRawSnapshotsClient.stream.<locals>._stream.<locals>.<genexpr>rU   r+   r.   r(   r/   r2   r3   rC   r   aiter_bytesareadr   r9   r0   r6   r7   r   r   r8   r   r   r:   rY   r[   r   r   r\     6   

z/AsyncRawSnapshotsClient.stream.<locals>._stream)	r   r4   r^   r	   r_   r   r6   AsyncIteratorra   rb   r   r[   r   r^   n  s   .zAsyncRawSnapshotsClient.streamc             	     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 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!   rA   rc   rG   r$   Nr    c               	      ro   )Nr&   r'   rM   rN   c                 S  rp   r   r   rP   r   r   r   rS     rq   zJAsyncRawSnapshotsClient.stream_archive.<locals>._stream.<locals>.<genexpr>rU   r+   r.   r(   r/   r2   rr   rY   r[   r   r   r\     ru   z7AsyncRawSnapshotsClient.stream_archive.<locals>._stream)r   r4   r^   r	   r   r6   rv   ra   rd   r   r[   r   re     s   .z&AsyncRawSnapshotsClient.stream_archive)rf   rg   rh   r   r   ri   r6   rj   r
   r   r   r?   r   rC   rk   asynccontextmanagerr_   rm   rv   ra   r^   re   r   r   r   r   rn     sZ    
3
5Hrn   )rk   r6   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   r7   Anyr_   r   rn   r   r   r   r   <module>   s"    n