
    >|h(#                         d dl 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 dd
lmZ ddlmZ  e j$                  e j&                  d      Z G d d      Z G d d      Zy)    N   )SyncClientWrapper)core)RequestOptions)UnprocessableEntityError)HttpValidationError)construct_type)JSONDecodeError)ApiError)AsyncClientWrapper.c                       e Zd ZdefdZdddej                  dej                  e	   dej                  e   fdZdddej                  dej                  e	   dej                  e   fd	Zy)
AudioIsolationClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     `/var/www/html/test/engine/venv/lib/python3.12/site-packages/elevenlabs/audio_isolation/client.py__init__zAudioIsolationClient.__init__   
    -    Nrequest_optionsaudior   returnc             #     K   | j                   j                  j                  ddi d|i|t              5 }	 d|j                  cxk  rdk  r>n n;||j                  dd	      nd	}|j                  |
      D ]  }|  	 ddd       y|j                          |j                  dk(  r@t        t        j                  t        t        t        |j                                           |j                         }t        |j                  |      # t        $ r" t        |j                  |j                         w xY w# 1 sw Y   yxY ww)a  
        Removes background noise from audio

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

        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.

        Yields
        ------
        typing.Iterator[bytes]
            Successful Response
        v1/audio-isolationPOSTr   methoddatafilesr   omit   ,  N
chunk_size   r(     type_object_status_codebodyr   httpx_clientstreamOMITr0   get
iter_bytesreadr   typingcastr   r	   jsonr
   r   textr   r   r   	_response_chunk_size_chunk_response_jsons          r   audio_isolationz$AudioIsolationClient.audio_isolation   sU    & !!..55  , 6 	
 	S W)//5#5M\Mh/"5"5lD"InrK"+"6"6+"6"N %$%	S 	S   ((C/2/*&9(1(8  "+!1 y'<'<>RR # W9+@+@y~~VVW9	S 	S;   2E	D=A	D 	E		A/D8D=+D::D==EE	c             #     K   | j                   j                  j                  ddi d|i|t              5 }	 d|j                  cxk  rdk  r>n n;||j                  dd	      nd	}|j                  |
      D ]  }|  	 ddd       y|j                          |j                  dk(  r@t        t        j                  t        t        t        |j                                           |j                         }t        |j                  |      # t        $ r" t        |j                  |j                         w xY w# 1 sw Y   yxY ww)a  
        Removes background noise from audio and streams the result

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

        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.

        Yields
        ------
        typing.Iterator[bytes]
            Successful Response
        v1/audio-isolation/streamr    r   r!   r&   r'   Nr(   r)   r*   r+   r,   r/   r2   r=   s          r   audio_isolation_streamz+AudioIsolationClient.audio_isolation_streamI   sU    & !!..55' , 6 	
 	S W)//5#5M\Mh/"5"5lD"InrK"+"6"6+"6"N %$%	S 	S   ((C/2/*&9(1(8  "+!1 y'<'<>RR # W9+@+@y~~VVW9	S 	SrC   )__name__
__module____qualname__r   r   r   Filer9   Optionalr   IteratorbytesrB   rF    r   r   r   r      s    .*; . W[1S		1S4:OON4S1S		1Sh W[1S		1S4:OON4S1S		1Sr   r   c                       e Zd ZdefdZdddej                  dej                  e	   dej                  e   fdZdddej                  dej                  e	   dej                  e   fd	Zy)
AsyncAudioIsolationClientr   c                    || _         y r   r   r   s     r   r   z"AsyncAudioIsolationClient.__init__~   r   r   Nr   r   r   r   c                 K   | j                   j                  j                  ddi d|i|t              4 d{   }	 d|j                  cxk  rdk  r:n n7||j                  dd	      nd	}|j                  |
      2 3 d{   }| |j                          d{    |j                  dk(  r@t        t        j                  t        t        t        |j                                           |j                         }t        |j                  |      7 7 6 	 ddd      d{  7   y7 # t        $ r" t        |j                  |j                         w xY w# 1 d{  7  sw Y   yxY ww)a  
        Removes background noise from audio

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

        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.

        Yields
        ------
        typing.AsyncIterator[bytes]
            Successful Response
        r   r    r   r!   Nr&   r'   r(   r)   r*   r+   r,   r/   r   r3   r4   r5   r0   r6   aiter_bytesareadr   r9   r:   r   r	   r;   r
   r   r<   r=   s          r   rB   z)AsyncAudioIsolationClient.audio_isolation   s    & ''44;;  , < 	
 	S 	S W)//5#5M\Mh/"5"5lD"InrK(1(=(=(=(U % %f$oo'''((C/2/*&9(1(8  "+!1 y'<'<>RR=	S%(U	S 	S 	S  ( # W9+@+@y~~VVW9	S 	S 	S   6E8DE8E#A D5>DDDD5 D3!A#D5E#E8DD5!E8,D/-E83D55+E  E##E5)E,*E51E8c                 K   | j                   j                  j                  ddi d|i|t              4 d{   }	 d|j                  cxk  rdk  r:n n7||j                  dd	      nd	}|j                  |
      2 3 d{   }| |j                          d{    |j                  dk(  r@t        t        j                  t        t        t        |j                                           |j                         }t        |j                  |      7 7 6 	 ddd      d{  7   y7 # t        $ r" t        |j                  |j                         w xY w# 1 d{  7  sw Y   yxY ww)a  
        Removes background noise from audio and streams the result

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

        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.

        Yields
        ------
        typing.AsyncIterator[bytes]
            Successful Response
        rE   r    r   r!   Nr&   r'   r(   r)   r*   r+   r,   r/   rS   r=   s          r   rF   z0AsyncAudioIsolationClient.audio_isolation_stream   s    & ''44;;' , < 	
 	S 	S W)//5#5M\Mh/"5"5lD"InrK(1(=(=(=(U % %f$oo'''((C/2/*&9(1(8  "+!1 y'<'<>RR=	S%(U	S 	S 	S  ( # W9+@+@y~~VVW9	S 	S 	SrV   )rG   rH   rI   r   r   r   rJ   r9   rK   r   AsyncIteratorrM   rB   rF   rN   r   r   rP   rP   }   s    .*< . W[1S		1S4:OON4S1S			e	$1Sh W[1S		1S4:OON4S1S			e	$1Sr   rP   )r9   core.client_wrapperr    r   core.request_optionsr   !errors.unprocessable_entity_errorr   types.http_validation_errorr   core.unchecked_base_modelr	   json.decoderr
   core.api_errorr   r   r:   Anyr5   r   rP   rN   r   r   <module>rb      sZ     3  1 H = 6 ( % 4 v{{6::s#hS hSVhS hSr   