
    љi                         S SK r S SKJrJrJr  S SKJrJrJr  S SK	J
r
Jr  SSKJr  \ R                  " \5      r " S S\
5      r " S	 S
\
5      r " S S\
5      r " S S5      rg)    N)DictAnyOptional)	APIRouterHTTPExceptionstatus)	BaseModelField   )SpeechDetectorc                      \ rS rSr% Sr\" SSS9r\\   \	S'   \" SSS9r
\\   \	S'   \" SS	S9r\\   \	S
'   \" SSS9r\\   \	S'   \" SSS9r\\   \	S'   \" SSS9r\\   \	S'   \" SSS9r\\   \	S'   \" SSS9r\\   \	S'    " S S5      rSrg)	VadConfig
   z
VadConfig is a data model that holds configuration settings for Voice Activity Detection (VAD) components.

All fields are optional and default to None if not provided.
NzhVolume threshold in dB for speech detection, e.g., -50.0. Set to null to disable volume-based filtering.)defaultdescriptionvolume_db_thresholdzFDuration of silence in seconds required to end a recording, e.g., 0.5.silence_duration_thresholdz2Maximum recording duration in seconds, e.g., 10.0.max_durationz]Minimum recording duration in seconds. Recordings shorter than this are discarded, e.g., 0.2.min_durationz%Audio sample rate in Hz, e.g., 16000.sample_ratez+Number of audio channels, e.g., 1 for mono.channelszDNumber of audio frames to buffer before speech is detected, e.g., 5.preroll_buffer_countzPFlag indicating whether to enable debug mode. If True, detailed logs are output.debugc                       \ rS rSrSrSrg)VadConfig.Config1   allow N)__name__
__module____qualname____firstlineno__extra__static_attributes__r       S/home/james-whalen/.local/lib/python3.13/site-packages/aiavatar/admin/config/vad.pyConfigr   1   s    r%   r'   r   )r   r    r!   r"   __doc__r
   r   r   float__annotations__r   r   r   r   intr   r   r   boolr'   r$   r   r%   r&   r   r   
   s    
 ,1~,%  38\3  %*H%L(5/  %*s%L(5/  "';"K#  $AHhsm  +0Z+(3-  "fE8D> 
 r%   r   c                   B    \ rS rSr% \" SS9r\\S'   \" SS9r\	\S'   Sr
g)	VadConfigResponse5   zType of VAD componentr   typeConfiguration of VAD componentconfigr   N)r   r    r!   r"   r
   r1   strr*   r3   r   r$   r   r%   r&   r.   r.   5   s,    +D#  4FI r%   r.   c                   ,    \ rS rSr% \" SS9r\\S'   Srg)UpdateVadConfigRequest>   r2   r0   r3   r   N)	r   r    r!   r"   r
   r3   r   r*   r$   r   r%   r&   r6   r6   >   s    4FI r%   r6   c                   (    \ rS rSrS\4S jrS rSrg)VadConfigAPID   vadc                     Xl         g )Nr;   )selfr;   s     r&   __init__VadConfigAPI.__init__E   s	     r%   c                    ^  [        5       nUR                  SS/SSSSS0SS0S	.S
9S[        4U 4S jj5       nUR                  SS/SSSSS0SS0SS0S.S
9S[        S[
        [        [        4   4U 4S jj5       nU$ )Nz/config/vadr'   zGet VAD configurationzARetrieve the current configuration settings for the VAD componentz_Current VAD configuration including volume threshold, silence/duration settings, and debug moder   z(Successfully retrieved VAD configurationzInternal server error)     )tagssummaryr   response_description	responsesreturnc            	        >#     TR                   n [        U R                  R                  [	        S0 U R                  5       D6S9$ ! [         a5  n[        R                  SU 35        [        [        R                  SS9eS nAff = f7f)N)r1   r3   z$Error retrieving VAD configuration: z8Internal server error while retrieving VAD configurationstatus_codedetailr   )r;   r.   	__class__r   r   
get_config	Exceptionloggererrorr   r   HTTP_500_INTERNAL_SERVER_ERROR)r;   exr>   s     r&   get_config_vad/VadConfigAPI.get_router.<locals>.get_config_vadN   s~     hh(//$8s~~'78 
  CB4HI# & E EU s)   BA A B
B0B  BBzUpdate VAD configurationzZUpdate configuration settings for the VAD component. Only non-null values will be updated.z;Dictionary of successfully updated configuration parametersz&Successfully updated VAD configurationz Invalid configuration parameters)rB   i  rC   requestc                    >#     TR                   nUR                  U R                  R                  5       5      $ ! [         a5  n[
        R                  SU 35        [        [        R                  SS9eS nAff = f7f)Nz"Error updating VAD configuration: z6Internal server error while updating VAD configurationrJ   )
r;   
set_configr3   
model_dumprO   rP   rQ   r   r   rR   )rV   r;   rS   r>   s      r&   post_config_vad0VadConfigAPI.get_router.<locals>.post_config_vadi   sl     	hh~~gnn&?&?&ABB A"FG# & E ES s%   A<4: A<
A90A44A99A<)r   getr.   postr6   r   r4   r   )r>   routerrT   rZ   s   `   r&   
get_routerVadConfigAPI.get_routerK   s    	+[ "C#%OP#%<= 
 


	&7 	


	  
.t!^#%MN#%GH#%<= 
 


	+A 
	d3PS8n 
	


	 r%   r=   N)r   r    r!   r"   r   r?   r_   r$   r   r%   r&   r9   r9   D   s    6r%   r9   )loggingtypingr   r   r   fastapir   r   r   pydanticr	   r
   sts.vadr   	getLoggerr   rP   r   r.   r6   r9   r   r%   r&   <module>rg      sY     & & 4 4 % %			8	$(	 (V	 Y = =r%   