
    b6i]6                        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j4                  ej6                  d      Z G d d      Z G d d      Zy)    N)JSONDecodeError   )core)ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)RequestOptions)construct_type)UnprocessableEntityError)HttpValidationError   )&AudioIsolationConvertRequestFileFormat)%AudioIsolationStreamRequestFileFormat.c                      e Zd Zdef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
       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       Zy)RawAudioIsolationClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     p/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/audio_isolation/raw_client.py__init__z RawAudioIsolationClient.__init__   
    -    Nfile_formatpreview_b_64request_optionsaudior    r!   r"   returnc          	   #      K   | j                   j                  j                  dd||dd|it        d      5 dt        t
        j                  t              ffd} |        d	d	d	       y	# 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

        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                     	 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>zCRawAudioIsolationClient.convert.<locals>._stream.<locals>.<genexpr>M        5xf5x   r3   responser,     type_object_headersbodystatus_coderE   rF   rH   getr
   
iter_bytesreadr   dictrE   typingcastr   r   jsonr   r   text_chunk_size_response_json	_responser"   s     r   _streamz0RawAudioIsolationClient.convert.<locals>._streamH   #   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   httpx_clientstreamOMITr
   rN   Iteratorbytesr   r#   r    r!   r"   rV   rU   s       ` @r   convertzRawAudioIsolationClient.convert   s     > !!..55 *+
  ,  6 
 )	 x\&//%*@A x4 )OS)	 )	 )	s   6A>/A2)	A>2A;7A>r    r"   c          	   #      K   | j                   j                  j                  ddd|id|it        d      5 dt        t
        j                  t              ffd} |        d	d	d	       y	# 1 sw Y   y	xY ww)
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                     	 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)Nr1   r2   r3   r4   c              3       K   | ]  }|  y wr   r6   r7   s     r   r:   zBRawAudioIsolationClient.stream.<locals>._stream.<locals>.<genexpr>   r;   r<   r=   r>   r@   rA   rD   rG   rI   rR   s     r   rV   z/RawAudioIsolationClient.stream.<locals>._stream   rW   rX   NrY   r   r#   r    r"   rV   rU   s      ` @r   r[   zRawAudioIsolationClient.streamd   s     6 !!..55'{  ,  6 
 (	 x\&//%*@A x4 )OQ(	 (	 (	s   5A=/A1(	A=1A:6A=)__name__
__module____qualname__r   r   
contextlibcontextmanagerr\   r   FilerN   Optionalr   strr   r]   r
   r^   r`   r   r[   r6   r   r   r   r      s'   .*; . 
 PT-1;?G yyG __%KL	G
 ooc*G  8G 
fooe&<=	>G GR 
 OS;?B yyB __%JK	B
  8B 
fooe&<=	>B Br   r   c                      e Zd Zdef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
       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       Zy)AsyncRawAudioIsolationClientr   c                    || _         y r   r   r   s     r   r   z%AsyncRawAudioIsolationClient.__init__   r   r   Nr   r#   r    r!   r"   r$   c          	     P  K   | j                   j                  j                  dd||dd|it        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  
        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                    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)Nr1   r2   r3   r4   c                2   K   | 3 d {   }| 7 
6 y wr   r6   r7   s     r   r:   zHAsyncRawAudioIsolationClient.convert.<locals>._stream.<locals>.<genexpr>        !k!k6&!k!k   r=   r>   r@   rA   rD   rG   rH   rJ   r	   aiter_bytesareadr   rM   rE   rN   rO   r   r   rP   r   r   rQ   rR   s     r   rV   z5AsyncRawAudioIsolationClient.convert.<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   rZ   r[   r\   r	   rN   AsyncIteratorr^   r_   s       ` @r   r`   z$AsyncRawAudioIsolationClient.convert   s     > ''44;; *+
  ,  < 
 *	" *	" x#4V5I5I%5P#Q x6  	/!U*	" *	" *	"T "U*	" *	" *	" *	"sW   :B&BB&0B2B3B:B&BB&BB&B#BB#B&ra   c          	     N  K   | j                   j                  j                  ddd|id|it        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]  
        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
        rc   r'   r    r#   Tr*   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)Nr1   r2   r3   r4   c                2   K   | 3 d {   }| 7 
6 y wr   r6   r7   s     r   r:   zGAsyncRawAudioIsolationClient.stream.<locals>._stream.<locals>.<genexpr>(  ru   rv   r=   r>   r@   rA   rD   rG   rw   rR   s     r   rV   z4AsyncRawAudioIsolationClient.stream.<locals>._stream"  rz   r{   r|   rf   s      ` @r   r[   z#AsyncRawAudioIsolationClient.stream   s     6 ''44;;'{  ,  < 
 )	" )	" x#4V5I5I%5P#Q x6  	/!S)	" )	" )	"R "S)	" )	" )	" )	"sW   9B%B
B%0B1B2B9B%BB%BB%B"BB"B%)rg   rh   ri   r   r   rj   asynccontextmanagerr\   r   rl   rN   rm   r   rn   r   r}   r	   r^   r`   r   r[   r6   r   r   rp   rp      s1   .*< . ##
 PT-1;?H" yyH" __%KL	H"
 ooc*H"  8H" 
		/0D0DU0KL	MH" $H"T ##
 OS;?C" yyC" __%JK	C"
  8C" 
		/0D0DU0KL	MC" $C"r   rp   )rj   rN   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   rO   Anyr\   r   rp   r6   r   r   <module>r      s_      (  % G @ 1 6 H = e c v{{6::s#Q QhS" S"r   