o
    lWi]6                     @   s   d dl 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	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 eejdZG dd dZG dd dZdS )    N)JSONDecodeError   )core)ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)RequestOptions)construct_type)UnprocessableEntityError)HttpValidationError   )&AudioIsolationConvertRequestFileFormat)%AudioIsolationStreamRequestFileFormat.c                   @      e Zd ZdefddZejeedddej	de
je de
je d	e
je d
e
jee
je   f
ddZejedddej	de
je d	e
je d
e
jee
je   fddZdS )RawAudioIsolationClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   i/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/audio_isolation/raw_client.py__init__      
z RawAudioIsolationClient.__init__Nfile_formatpreview_b_64request_optionsaudior   r    r!   returnc             	   #   st    | j jjdd||dd|itdd dttjt  f fdd	}| V  W d
   d
S 1 s3w   Y  d
S )a  
        Removes background noise from audio.

        Parameters
        ----------
        audio : core.File
            See core.File for more documentation

        file_format : typing.Optional[AudioIsolationConvertRequestFileFormat]
            The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform.

        preview_b_64 : typing.Optional[str]
            Optional preview image base64 for tracking this generation.

        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/audio-isolationPOSTr   preview_b64r"   Tmethoddatafilesr!   omitforce_multipartr#   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)N   ,  
chunk_size   c                 s       | ]}|V  qd S r   r   .0_chunkr   r   r   	<genexpr>M       zCRawAudioIsolationClient.convert.<locals>._stream.<locals>.<genexpr>r1   responser*     type_object_headersbodystatus_coderA   rB   rD   getr	   
iter_bytesreadr   dictrA   typingcastr   r   jsonr   r   text_chunk_size_response_json	_responser!   r   r   _streamH   2   

z0RawAudioIsolationClient.convert.<locals>._streamNr   httpx_clientstreamOMITr	   rJ   Iteratorbytesr   r"   r   r    r!   rS   r   rQ   r   convert   s"   
"zRawAudioIsolationClient.convertr   r!   c             	   #   sr    | j jjddd|id|itdd dttjt  f fdd	}| V  W d
   d
S 1 s2w   Y  d
S )aN  
        Removes background noise from audio.

        Parameters
        ----------
        audio : core.File
            See core.File for more documentation

        file_format : typing.Optional[AudioIsolationStreamRequestFileFormat]
            The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform.

        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/audio-isolation/streamr%   r   r"   Tr(   r#   c               	      r.   )Nr/   r0   r1   r2   c                 s   r3   r   r   r4   r   r   r   r7      r8   zBRawAudioIsolationClient.stream.<locals>._stream.<locals>.<genexpr>r9   r:   r<   r=   r@   rC   rE   rN   rQ   r   r   rS      rT   z/RawAudioIsolationClient.stream.<locals>._streamNrU   r   r"   r   r!   rS   r   rQ   r   rW   d   s    
"zRawAudioIsolationClient.stream)__name__
__module____qualname__r   r   
contextlibcontextmanagerrX   r   FilerJ   Optionalr   strr
   rY   r	   rZ   r\   r   rW   r   r   r   r   r      s:    Ir   c                   @   r   )AsyncRawAudioIsolationClientr   c                C   r   r   r   r   r   r   r   r      r   z%AsyncRawAudioIsolationClient.__init__Nr   r"   r   r    r!   r#   c             	     s   | j jjdd||dd|it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 s@w   Y  dS )a  
        Removes background noise from audio.

        Parameters
        ----------
        audio : core.File
            See core.File for more documentation

        file_format : typing.Optional[AudioIsolationConvertRequestFileFormat]
            The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform.

        preview_b_64 : typing.Optional[str]
            Optional preview image base64 for tracking this generation.

        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"   Tr(   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/   r0   r1   r2   c                 S     | z	3 d H W }|V  q6 d S r   r   r4   r   r   r   r7          zHAsyncRawAudioIsolationClient.convert.<locals>._stream.<locals>.<genexpr>r9   r:   r<   r=   r@   rC   rD   rF   r   aiter_bytesareadr   rI   rA   rJ   rK   r   r   rL   r   r   rM   rN   rQ   r   r   rS      6   

z5AsyncRawAudioIsolationClient.convert.<locals>._streamr   rV   rW   rX   r   rJ   AsyncIteratorrZ   r[   r   rQ   r   r\      s"   .z$AsyncRawAudioIsolationClient.convertr]   c             	     s   | j jjddd|id|it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 s?w   Y  dS )a]  
        Removes background noise from audio.

        Parameters
        ----------
        audio : core.File
            See core.File for more documentation

        file_format : typing.Optional[AudioIsolationStreamRequestFileFormat]
            The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform.

        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"   Tr(   Nr#   c               	      ri   )Nr/   r0   r1   r2   c                 S  rj   r   r   r4   r   r   r   r7   (  rk   zGAsyncRawAudioIsolationClient.stream.<locals>._stream.<locals>.<genexpr>r9   r:   r<   r=   r@   rC   rl   rN   rQ   r   r   rS   "  ro   z4AsyncRawAudioIsolationClient.stream.<locals>._streamrp   r_   r   rQ   r   rW      s    .z#AsyncRawAudioIsolationClient.stream)r`   ra   rb   r   r   rc   asynccontextmanagerrX   r   re   rJ   rf   r   rg   r
   rq   r   rZ   r\   r   rW   r   r   r   r   rh      s:    Jrh   )rc   rJ   json.decoderr    r   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.request_optionsr
   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr   types.http_validation_errorr   1types.audio_isolation_convert_request_file_formatr   0types.audio_isolation_stream_request_file_formatr   rK   AnyrX   r   rh   r   r   r   r   <module>   s"    