+
    >j"                         ^RI HtHtHtHtHtHtHtH	t	H
t
Ht ^RIHtHtHt ^RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIt] ! R R	4      4       tR
 R lt Rt ! R R]P8                  ]P:                  ,          4      tR# )   )
EnhancerEnhancerSettingsModelParametersEnhancerModelEnhancerError
StreamInfoCredentialsNativeAudioBufferMutVadSettingsmodel_parameters_equal)AuthAuthBaseLiveKitCloud)logger)rtc)Optional)	dataclassNc                   :   a  ] tR t^t o RtRtR tV 3R ltRtV t	R# )r   Nc                D    \        V P                  V P                  R 7      # ))enhancement_levelbypass)ModelParametersUniffir   r   selfs   &w/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/livekit/plugins/ai_coustics/plugin.py
_to_uniffiModelParameters._to_uniffi   s    $"44;;
 	
    c                R   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   # )   r   r   )r   float)format__classdict__s   "r   __annotate__ModelParameters.__annotate__   s%     -  UO" r    )
__name__
__module____qualname____firstlineno__r   r   r   __annotate_func____static_attributes____classdictcell__r#   s   @r   r   r      s     )-"F
  r   r   c                f    V ^8  d   QhR\         R\        \        P                  \        3,          /# )r    datareturn)
memoryviewtuplenpndarrayr
   )r"   s   "r   r$   r$   #   s)     " ": "%

<P0P*Q "r   c                    \         P                  ! V \         P                  R7      P                  \         P                  RR7      R,          pVP
                  P                  p\        V\        V4      R7      pW3# )z
Convert frame.data (int16 memoryview) to NativeAudioBufferMut (f32 pointer).
Returns both the numpy array (to keep it alive) and the NativeAudioBufferMut.
)dtypeT)copyg      @)ptrlen)	r4   
frombufferint16astypefloat32ctypesr0   r
   r:   )r0   samples	ptr_valuenative_buffers   &   r   to_native_bufferrC   #   sf     	d"((+222::D2IGS 
 ##I )LM
 !!r   z
lk.aic-vadc                     a  ] tR t^@t o RRRR/V 3R lR llt]V 3R lR l4       t]P                  V 3R lR	 l4       tV 3R
 lR ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltR tRtV tR# )AICousticsAudioEnhancermodel_parametersNauthc          
      V   < V ^8  d   QhRS[ RS[RS[S[,          RS[S[,          RR/# )r    modelvad_settingsrF   rG   r1   N)r   r   r   r   r   )r"   r#   s   "r   r$   $AICousticsAudioEnhancer.__annotate__B   sI        "	
 #?3 x  
r   c                   Wn         W n        W0n        T;'       g    \        P                  ! 4       V n        R V n        R V n        R V n        R V n	        R V n
        RV n        R # )NT)_model_vad_settings_model_parametersr   livekit_cloud_auth_last_error_msg	_enhancer_info_credentials	_settings_enabled)r   rI   rJ   rF   rG   s   &$$$$r   __init__ AICousticsAudioEnhancer.__init__B   sY     )!111T//1
.2*.(,
0426r   c                    < V ^8  d   QhRS[ /# r    r1   bool)r"   r#   s   "r   r$   rK   W   s       r   c                    V P                   # NrW   r   s   &r   enabledAICousticsAudioEnhancer.enabledV   s    }}r   c                $   < V ^8  d   QhRS[ RR/# )r    valuer1   Nr\   )r"   r#   s   "r   r$   rK   [   s      T d r   c                    Wn         R # r_   r`   )r   rd   s   &&r   ra   rb   Z   s    r   c                    < V ^8  d   QhRS[ /# )r    rF   )r   )r"   r#   s   "r   r$   rK   ^   s     ; ; ;r   c                L   V P                   '       g   \        P                  ! R4       R# VP                  4       pV P                  e   V P                  P                  4       M\        RRR7      p\        W#4      '       d   R# Wn        V P                   P                  V4       R# )aq  
Updates the model parameters on the running model.

The native core must already exist (i.e. at least one audio frame must
have been processed) for the update to take effect; otherwise the call
is a no-op and a warning is logged. The new parameters are also stored
so they are reapplied if the native core is later recreated (e.g. on a
sample-rate or channel change).
zkupdate_model_parameters: Native core not yet initialized, skipping. Process at least one audio frame first.Nr   r   )rS   r   warningr   rO   r   r   update_model_parameters)r   rF   
new_unifficurrent_uniffis   &&  r   rj   /AICousticsAudioEnhancer.update_model_parameters^   s     ~~~NN  I  J%002
 %%1 ""--/&ddK 	
 "*==!1..z:r   c                ,   < V ^8  d   QhRS[ RS[ RS[ /# )r    	room_nameparticipant_identitypublication_sidstr)r"   r#   s   "r   r$   rK   v   s%     : ::7::MP:r   c                   \        R VVR VR7      V n        V P                  e(   V P                  P                  V P                  4       R# R# ) )room_idro   rp   participant_idtrack_idN)r   rT   rS   update_stream_info)r   ro   rp   rq   s   &$$$r   _on_stream_info_updated/AICousticsAudioEnhancer._on_stream_info_updatedv   sF      !5$

 >>%NN--djj9 &r   c                &   < V ^8  d   QhRS[ RS[ /# )r    tokenurlrr   )r"   r#   s   "r   r$   rK      s     A A A# Ar   c                   \        WR 7      V n        V P                  e(   V P                  P                  V P                  4       R# R# ))r}   r~   N)r	   rU   rS   update_credentials)r   r}   r~   s   &$$r   _on_credentials_updated/AICousticsAudioEnhancer._on_credentials_updated   s6    'e=>>%NN--d.?.?@ &r   c                N   < V ^8  d   QhRS[ P                  RS[ P                  /# )r    framer1   )r   
AudioFrame)r"   r#   s   "r   r$   rK      s'     I Icnn I Ir   c                   V P                   '       g   V# V P                  P                  V P                  4      pVf   V P	                  R4       V# V P                  4       '       d&   V P                  '       g   V P	                  R4       V# V P                  4       '       d"   V P                  f   V P	                  R4       V# V P                  e   V P                  Ee=   V P                  P                  VP                  8w  gK   V P                  P                  VP                  8w  g&   V P                  P                  VP                  8w  d   \        VP                  VP                  VP                  V P                  V P                  '       d   V P                  P!                  4       M\#        RRR7      V P$                  R7      V n	         \'        W P                  4      V n        T P                  e&   T P                  P-                  T P                  4       \/        VP0                  4      w  rE V P                  P3                  V4      p\4        P6                  ! TRR4      R,          P9                  \4        P:                  4      p\<        P>                  ! TPA                  4       TP                  TP                  TP                  TPB                  R7      pYhPB                  \D        &   T#   \(         d0   pT P	                  RT R24       RT n        R	T n        Tu Rp?# Rp?ii ; i  \(         d!   pT P	                  R
T 24       Tu Rp?# Rp?ii ; i)z
Processes a single audio frame.

If the frame processor is disabled or processing fails, the original frame is
returned unchanged.
NzMissing auth modezMissing credentialszMissing stream inforh   )sample_ratenum_channelssamples_per_channelrI   rF   vadz"Failed to initialize plugin core: z? - Disabling noise cancellation for all following audio frames.FzProcessing failed: g      ?g    @)r0   r   r   r   userdatag      )#ra   rQ   _to_auth_moderU   _log_process_frame_error_auth_mode_requires_credentials_auth_mode_requires_stream_inforT   rS   rV   r   r   r   r   rM   rO   r   r   rN   r   r   rW   ry   rC   r0   process_with_vadr4   clipr=   r<   r   r   tobytesr    FRAME_USERDATA_AIC_VAD_ATTRIBUTE)	r   r   	auth_modeer@   rB   vad_dataprocessed_int16output_frames	   &&       r   _process AICousticsAudioEnhancer._process   s    |||LJJ,,T->->?	))*=>L//11$:K:K:K))*?@L//11djj6H))*?@L >>!NN&**e.?.??>>..%2D2DD>>559R9RR .!--"//$)$=$=kkHLH^H^H^!7!7!B!B!Ddy  BF  Z^  e_&&DN!))^^!D zz%11$**= "2%**!=	~~66}EH 777D#6@HHR~~ ((*))++ % 9 9^^
 CK>?= ! --0RSTRU  VU  /V  W!% %	  	)),?s*CDL	s<   K0 4L- 0L*;$L%L*%L*-M8MMMc                    < V ^8  d   QhRS[ /# r[   r\   )r"   r#   s   "r   r$   rK      s     4 4 4r   c                6    \        V P                  \        4      # )z>Does the given auth mode require update_stream_info be called?
isinstancerQ   r   r   s   &r   r   7AICousticsAudioEnhancer._auth_mode_requires_stream_info   s    $**l33r   c                    < V ^8  d   QhRS[ /# r[   r\   )r"   r#   s   "r   r$   rK      s     4 4 4r   c                6    \        V P                  \        4      # )z
Does the given auth mode require update_credentials be called?

Note that this is just here to provide helpful warnings to users,
the actual auth layer is in the rust core.
r   r   s   &r   r   7AICousticsAudioEnhancer._auth_mode_requires_credentials   s     $**l33r   c                    < V ^8  d   QhRS[ /# )r    msgrr   )r"   r#   s   "r   r$   rK      s     	 	C 	r   c                d    V P                   V8X  d   R# Wn         \        P                  ! V4       R# )z
Logs a new error to the screen when processing a frame.
Only shows logs which were newly introduced as compared with the
last processed frame.
N)rR   r   error)r   r   s   &&r   r   0AICousticsAudioEnhancer._log_process_frame_error   s'     3&"Sr   c                4    V P                   e
   R V n         R # R # r_   )rS   r   s   &r   _closeAICousticsAudioEnhancer._close   s    >>%!DN &r   )
rQ   rU   rW   rS   rT   rR   rM   rO   rV   rN   )r'   r(   r)   r*   rX   propertyra   setterrj   rz   r   r   r   r   r   r   r,   r-   r.   s   @r   rE   rE   @   s     
 7; $( (   ^^ ; ;0: :A A
I IV4 44 4	 	" "r   rE   )_ffir   r   r   r   r   r   r   r	   r
   r   r   rG   r   r   r   logr   livekitr   typingr   dataclassesr   numpyr4   rC   r   FrameProcessorr   rE   r&   r   r   <module>r      sq      / .    ! 

 
 
",
 $0  m"c00@ m"r   