+
    ~j!                     Z    ^ RI t ^RIHt ^RIHt ^RIHtHt ^ RI	H
t
Ht  ! R R4      tR# )    N)	FfiHandle)audio_frame_pb2)_ensure_compatible_bufferget_address)AnyUnionc                   p  a  ] tR t^t o RtRR/V 3R lR llt]V 3R lR l4       t]V 3R lR	 l4       tV 3R
 lR lt	]
V 3R lR l4       t]
V 3R lR l4       t]
V 3R lR l4       t]
V 3R lR l4       t]
V 3R lR l4       t]
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4       tRtV tR# )
AudioFramez
A class that represents a frame of audio data with specific properties such as sample rate,
number of channels, and samples per channel.

The format of the audio data is 16-bit signed integers (int16) interleaved by channel.
userdataNc                   < V ^8  d   QhRS[ S[S[S[3,          RS[RS[RS[RS[ S[S[S[3,          R3,          RR/# )   datasample_ratenum_channelssamples_per_channelr   Nreturn)r   bytes	bytearray
memoryviewintdictstrr   )format__classdict__s   "l/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/livekit/rtc/audio_frame.py__annotate__AudioFrame.__annotate__   se     ,> ,>E9j01,> ,> 	,>
 !,> S#X,-,> 
,>    c                  \        V\        4      '       d   VP                  R4      p\        V4      pW4,          \        P
                  ! \        P                  4      ,          p\        V4      pWv8  d   \        R4      hV\        P
                  ! \        P                  4      ,          ^ 8w  d   \        R4      hWn	        W n
        W0n        W@n        Vf
   / V n        R# TV n        R# )a  
Initialize an AudioFrame instance.

Args:
    data (Union[bytes, bytearray, memoryview]): The raw audio data, which must be at least
        `num_channels * samples_per_channel * sizeof(int16)` bytes long.
    sample_rate (int): The sample rate of the audio in Hz.
    num_channels (int): The number of audio channels (e.g., 1 for mono, 2 for stereo).
    samples_per_channel (int): The number of samples per channel.

Raises:
    ValueError: If the length of `data` is smaller than the required size.
BzIdata length must be >= num_channels * samples_per_channel * sizeof(int16)z/data length must be a multiple of sizeof(int16)N)
isinstancer   castr   ctypessizeofc_int16len
ValueError_data_sample_rate_num_channels_samples_per_channel	_userdata)selfr   r   r   r   r   min_sizedata_lens   &&&&&$  r   __init__AudioFrame.__init__   s    , dJ''99S>D(.5fnn8UUt9[  fmmFNN33q8NOO
')$7!'/Xr   c                0   < V ^8  d   QhRS[ RS[ RS[ RR/# )r   r   r   r   r   r
   r   )r   r   s   "r   r   r   M   s0     P PC Ps P PQ] Pr   c                    W,          \         P                  ! \         P                  4      ,          p\        V4      p\	        W@W4      # )a  
Create a new empty AudioFrame instance with specified sample rate, number of channels,
and samples per channel.

Args:
    sample_rate (int): The sample rate of the audio in Hz.
    num_channels (int): The number of audio channels (e.g., 1 for mono, 2 for stereo).
    samples_per_channel (int): The number of samples per channel.

Returns:
    AudioFrame: A new AudioFrame instance with uninitialized (zeroed) data.
)r#   r$   r%   r   r
   )r   r   r   sizer   s   &&&  r   createAudioFrame.createL   s4     1FMM&..4QQ$\OOr   c                8   < V ^8  d   QhRS[ P                  RR/# )r   
owned_infor   r
   )proto_audioOwnedAudioFrameBuffer)r   r   s   "r   r   r   _   s%     _ _[%F%F _< _r   c                z   V P                   pVP                  VP                  ,          p\        P                  V,          P                  VP                  4      p\        V4      p\        V P                  P                  4      P                  4        \        WAP                  VP                  VP                  4      # N)infor   r   r#   r%   from_addressdata_ptrr   r   handleiddisposer
   r   )r9   r>   r5   cdatar   s   &    r   _from_owned_infoAudioFrame._from_owned_info^   s      4#;#;;$&44T]]C*##&&'//1$ 0 0$2C2CTE]E]^^r   c                4   < V ^8  d   QhRS[ P                  /# r   r   )r:   AudioFrameBufferInfo)r   r   s   "r   r   r   g   s      [== r   c                    \         P                  ! 4       p\        V P                  4      Vn        V P
                  Vn        V P                  Vn        V P                  Vn        V# r=   )r:   rI   r   r(   r@   r   r   r   )r-   
audio_infos   & r   _proto_infoAudioFrame._proto_infog   sQ     557
)$**5
!%!1!1
"&"3"3
)-)A)A
&r   c                6   < V ^8  d   QhRS[ S[S[3,          /# rH   )r   r   r   )r   r   s   "r   r   r   p   s      $sCx. r   c                    V P                   # )z8
Returns the user data associated with the audio frame.
)r,   r-   s   &r   r   AudioFrame.userdatao   s    
 ~~r   c                    < V ^8  d   QhRS[ /# rH   )r   )r   r   s   "r   r   r   w   s     : :j :r   c                h    \        V P                  4      P                  R4      P                  R4      # )z
Returns a memory view of the audio data as 16-bit signed integers.

Returns:
    memoryview: A memory view of the audio data.
r    h)r   r(   r"   rP   s   &r   r   AudioFrame.datav   s)     $**%**3/44S99r   c                    < V ^8  d   QhRS[ /# rH   r3   )r   r   s   "r   r   r      s     ! !S !r   c                    V P                   # )zW
Returns the sample rate of the audio frame.

Returns:
    int: The sample rate in Hz.
)r)   rP   s   &r   r   AudioFrame.sample_rate   s        r   c                    < V ^8  d   QhRS[ /# rH   r3   )r   r   s   "r   r   r      s     " "c "r   c                    V P                   # )z
Returns the number of channels in the audio frame.

Returns:
    int: The number of audio channels (e.g., 1 for mono, 2 for stereo).
)r*   rP   s   &r   r   AudioFrame.num_channels   s     !!!r   c                    < V ^8  d   QhRS[ /# rH   r3   )r   r   s   "r   r   r      s     ) )S )r   c                    V P                   # )zb
Returns the number of samples per channel.

Returns:
    int: The number of samples per channel.
)r+   rP   s   &r   r   AudioFrame.samples_per_channel   s     (((r   c                    < V ^8  d   QhRS[ /# rH   )float)r   r   s   "r   r   r      s     ; ;% ;r   c                <    V P                   V P                  ,          # )zc
Returns the duration of the audio frame in seconds.

Returns:
    float: The duration in seconds.
)r   r   rP   s   &r   durationAudioFrame.duration   s     ''$*:*:::r   c                    < V ^8  d   QhRS[ /# rH   )r   )r   r   s   "r   r   r      s     ' 'e 'r   c           	        ^ RI p^ RIpVP                  4       ;_uu_ 4       pVP                  VR4      ;_uu_ 4       pVP	                  V P
                  4       VP                  ^4       VP                  V P                  4       VP                  V P                  4       RRR4       VP                  4       uuRRR4       #   + '       g   i     L*; i  + '       g   i     R# ; i)zy
Convert the audio frame data to a WAV-formatted byte stream.

Returns:
    bytes: The audio data encoded in WAV format.
Nwb)waveioBytesIOopensetnchannelsr   setsampwidthsetframerater   writeframesr(   getvalue)r-   rg   rh   wav_filewavs   &    r   to_wav_bytesAudioFrame.to_wav_bytes   s     	ZZ\\X8T**c  !2!23  #  !1!12

+	 + $$& \** \\s#   CA#C	CCCC%	c                    < V ^8  d   QhRS[ /# rH   )r   )r   r   s   "r   r   r      s     
 
# 
r   c           	     r    R V P                    RV P                   RV P                   RV P                  R R2	# )zrtc.AudioFrame(sample_rate=z, num_channels=z, samples_per_channel=z, duration=z.3f))r   r   r   rb   rP   s   &r   __repr__AudioFrame.__repr__   sO    )$*:*:); < --. /##'#;#;"< =c*!-	
r   c                    < V ^8  d   QhRS[ /# )r   _r   )r   r   s   "r   r   r      s     .
 .
c .
r   c                  a ^ RI Hp ^ RIoR V3R llpVP                  VP	                  VP                  RVP                  VP                  4       4      RVP                  VP                  4       4      RVP                  VP                  4       4      RVP                  VP                  4       4      /4      VP                  V4      .4      VP                  V4      VP                  V3R	 l4      R
7      # )r   )core_schemaNc                (    V ^8  d   QhR\         RR/# )r   valuer   r
   r{   )r   s   "r   r   =AudioFrame.__get_pydantic_core_schema__.<locals>.__annotate__   s     	; 	; 	; 	;r   c                 (  < \        V \        4      '       d   V # \        V \        4      '       d
   V ^ ,          p \        V \        4      '       d;   \        SP	                  V R,          4      V R,          V R,          V R,          R7      # \        R4      h)r   r   r   r   r   )r   r   r   r   zInvalid type for AudioFrame)r!   r
   tupler   	b64decode	TypeError)r   base64s   &r   validate_audio_frameEAudioFrame.__get_pydantic_core_schema__.<locals>.validate_audio_frame   s~    %,,%''a%&&!))%-8 %m 4!&~!6(-.C(D	  9::r   r   r   r   r   c                    < R SP                  V P                  4      P                  R4      RV P                  RV P                  RV P
                  /# )r   zutf-8r   r   r   )	b64encoder   decoder   r   r   )instancer   s   &r   <lambda>9AudioFrame.__get_pydantic_core_schema__.<locals>.<lambda>   sH    F,,X]];BB7K!8#7#7"H$9$9)8+G+G	"r   )json_schemapython_schemaserialization)pydantic_corer}   r   json_or_python_schemachain_schemamodel_fields_schemamodel_field
str_schema
int_schema no_info_plain_validator_function$plain_serializer_function_ser_schema)clsrz   r}   r   r   s   &*  @r   __get_pydantic_core_schema__'AudioFrame.__get_pydantic_core_schema__   s    -	; 	;" 00#0033"K$;$;K<R<R<T$U);+B+B;CYCYC[+\*K,C,CKDZDZD\,]1;3J3J + 6 6 84		  @@AUV &FFG[\%JJ# 1 
 	
r   )r(   r*   r)   r+   r,   )__name__
__module____qualname____firstlineno____doc__r0   staticmethodr6   rE   rL   propertyr   r   r   r   r   rb   rr   rw   classmethodr   __static_attributes____classdictcell__)r   s   @r   r
   r
      s     ,> 15,> ,>\ P P" _ _    : : ! ! " " ) ) ; ;' '&
 
 .
 .
r   r
   )r#   _ffi_clientr   _protor   r:   _utilsr   r   typingr   r   r
    r   r   <module>r      s"     " 2 : \
 \
r   