
    qi                        d Z ddlZddlZddlmZ ddlmZmZmZ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mZmZmZmZmZmZmZmZmZmZmZ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*m+Z+ ddl,m-Z- 	 ddl.m/Z/ ddl0m1Z2 ddl3m4Z4m5Z5m6Z6 ddddddddddddd Z;e G d! d"e             Z<e G d# d$e             Z=e G d% d&e<             Z>e G d' d(e=             Z? G d) d*e+      Z@ G d+ d,e      ZA G d- d.      ZB G d/ d0e&      ZC G d1 d2e(      ZD G d3 d4e*      ZEy# e7$ r7Z8 ejr                  de8         ejr                  d        e:de8       dZ8[8ww xY w)5zLiveKit transport implementation for Pipecat.

This module provides comprehensive LiveKit real-time communication integration
including audio streaming, data messaging, participant management, and room
event handling for conversational AI applications.
    N)	dataclass)Any	AwaitableCallableListOptional)logger)	BaseModel)create_stream_resampler)VADAnalyzer)AudioRawFrameBotConnectedFrameCancelFrameClientConnectedFrameEndFrameImageRawFrameOutputAudioRawFrameOutputDTMFFrameOutputDTMFUrgentFrameOutputTransportMessageFrame!OutputTransportMessageUrgentFrame
StartFrameUserAudioRawFrameUserImageRawFrame)FrameDirectionFrameProcessorSetup)BaseInputTransport)BaseOutputTransport)BaseTransportTransportParams)BaseTaskManager)rtc)video_frame_pb2)retrystop_after_attemptwait_exponentialzException: zGIn order to use LiveKit, you need to `pip install pipecat-ai[livekit]`.zMissing module:                         	   
      )0123456789*#c                   &    e Zd ZU dZdZee   ed<   y)"LiveKitOutputTransportMessageFrameFrame for transport messages in LiveKit rooms.

    Parameters:
        participant_id: Optional ID of the participant this message is for/from.
    Nparticipant_id__name__
__module____qualname____doc__rA   r   str__annotations__     V/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/transports/livekit/transport.pyr?   r?   H        %)NHSM(rJ   r?   c                   &    e Zd ZU dZdZee   ed<   y)(LiveKitOutputTransportMessageUrgentFrameFrame for urgent transport messages in LiveKit rooms.

    Parameters:
        participant_id: Optional ID of the participant this message is for/from.
    NrA   rB   rI   rJ   rK   rN   rN   S   rL   rJ   rN   c                   "     e Zd ZdZ fdZ xZS )LiveKitTransportMessageFramer@   c                     t         |           dd l}|j                         5  |j	                  d       |j                  dt        d       d d d        y # 1 sw Y   y xY w)Nr   alwayszLiveKitTransportMessageFrame is deprecated and will be removed in a future version. Instead, use LiveKitOutputTransportMessageFrame.r(   
stacklevelsuper__post_init__warningscatch_warningssimplefilterwarnDeprecationWarningselfrY   	__class__s     rK   rX   z*LiveKitTransportMessageFrame.__post_init__f   s]    $$& 	!!(+MMC"	  	 	 	   *AA rC   rD   rE   rF   rX   __classcell__r`   s   @rK   rQ   rQ   ^        rJ   rQ   c                   "     e Zd ZdZ fdZ xZS )"LiveKitTransportMessageUrgentFramerO   c                     t         |           dd l}|j                         5  |j	                  d       |j                  dt        d       d d d        y # 1 sw Y   y xY w)Nr   rS   zLiveKitTransportMessageUrgentFrame is deprecated and will be removed in a future version. Instead, use LiveKitOutputTransportMessageUrgentFrame.r(   rT   rV   r^   s     rK   rX   z0LiveKitTransportMessageUrgentFrame.__post_init__|   s]    $$& 	!!(+MMI"	  	 	 	ra   rb   rd   s   @rK   rg   rg   t   re   rJ   rg   c                       e Zd ZdZy)LiveKitParamszConfiguration parameters for LiveKit transport.

    Inherits all parameters from TransportParams without additional configuration.
    N)rC   rD   rE   rF   rI   rJ   rK   rj   rj      s    
 	rJ   rj   c                   B   e Zd ZU dZeg ed   f   ed<   eg ed   f   ed<   eg ed   f   ed<   eeged   f   ed<   eeged   f   ed<   eeged   f   ed<   eeged   f   ed	<   eeged   f   ed
<   eeged   f   ed<   eeeged   f   ed<   eeged   f   ed<   y)LiveKitCallbacksa  Callback handlers for LiveKit events.

    Parameters:
        on_connected: Called when connected to the LiveKit room.
        on_disconnected: Called when disconnected from the LiveKit room.
        on_participant_connected: Called when a participant joins the room.
        on_participant_disconnected: Called when a participant leaves the room.
        on_audio_track_subscribed: Called when an audio track is subscribed.
        on_audio_track_unsubscribed: Called when an audio track is unsubscribed.
        on_data_received: Called when data is received from a participant.
        on_first_participant_joined: Called when the first participant joins.
    Non_connectedon_disconnectedon_before_disconnecton_participant_connectedon_participant_disconnectedon_audio_track_subscribedon_audio_track_unsubscribedon_video_track_subscribedon_video_track_unsubscribedon_data_receivedon_first_participant_joined)	rC   rD   rE   rF   r   r   rH   rG   bytesrI   rJ   rK   rl   rl      s     2y.//b)D/122"2y#677&uio'=>>!)3%4*@!AA'y(>??!)3%4*@!AA'y(>??!)3%4*@!AAs|Yt_<==!)3%4*@!AArJ   rl   c                      e Zd ZdZdedededededefdZed	efd
       Z	ed	e
j                  fd       ZdefdZd ZdefdZ e ed       eddd            d        Zd Zd?dedee   fdZdefdZde
j6                  d	efd Zd	ee   fd!Zded	e fd"Z!d#efd$Z"defd%Z#defd&Z$d'e
jJ                  fd(Z&d'e
jJ                  fd)Z'd*e
jP                  d+e
jR                  d'e
jJ                  fd,Z*d*e
jP                  d+e
jR                  d'e
jJ                  fd-Z+de
jX                  fd.Z-d/ Z.d0 Z/d'e
jJ                  fd1Z0d'e
jJ                  fd2Z1d*e
jP                  d+e
jR                  d'e
jJ                  fd3Z2d*e
jP                  d+e
jR                  d'e
jJ                  fd4Z3de
jX                  fd5Z4d6 Z5d?d7Z6d8e
jn                  defd9Z8d: Z9d;e
jt                  defd<Z;d= Z<d> Z=y)@LiveKitTransportClientzCore client for interacting with LiveKit rooms.

    Manages the connection to LiveKit rooms and handles all low-level API interactions
    including room management, audio streaming, data messaging, and event handling.
    urltoken	room_nameparams	callbackstransport_namec                 z   || _         || _        || _        || _        || _        || _        d| _        d| _        d| _        d| _	        d| _
        d| _        i | _        t        j                         | _        i | _        t        j                         | _        d| _        d| _        t        j(                         | _        y)a  Initialize the LiveKit transport client.

        Args:
            url: LiveKit server URL to connect to.
            token: Authentication token for the room.
            room_name: Name of the LiveKit room to join.
            params: Configuration parameters for the transport.
            callbacks: Event callback handlers.
            transport_name: Name identifier for the transport.
        N Fr   )_url_token
_room_name_params
_callbacks_transport_name_room_participant_id
_connected_disconnect_counter_audio_source_audio_track_audio_tracksasyncioQueue_audio_queue_video_tracks_video_queue_other_participant_has_joined_task_managerLock_async_lock)r_   r{   r|   r}   r~   r   r   s          rK   __init__zLiveKitTransportClient.__init__   s    & 	##-)-
$&#$ 8<;?#MMO#MMO-2*8<"<<>rJ   returnc                     | j                   S )zvGet the participant ID for this client.

        Returns:
            The participant ID assigned by LiveKit.
        )r   r_   s    rK   rA   z%LiveKitTransportClient.participant_id   s     ###rJ   c                 N    | j                   st        |  d      | j                   S )zGet the LiveKit room instance.

        Returns:
            The LiveKit room object.

        Raises:
            Exception: If room object is not available.
        z-: missing room object (pipeline not started?))r   	Exceptionr   s    rK   roomzLiveKitTransportClient.room   s(     zztf$QRSSzzrJ   setupc                   K   | j                   ry|j                  | _         t        j                  | j                   j	                               | _         | j                  j                  d      | j                          | j                  j                  d      | j                          | j                  j                  d      | j                          | j                  j                  d      | j                          | j                  j                  d      | j                          | j                  j                  d      | j                          | j                  j                  d	      | j                         yw)
zSetup the client with task manager and room initialization.

        Args:
            setup: The frame processor setup configuration.
        N)loopparticipant_connectedparticipant_disconnectedtrack_subscribedtrack_unsubscribeddata_received	connecteddisconnected)r   task_managerr"   Roomget_event_loopr   r   on!_on_participant_connected_wrapper$_on_participant_disconnected_wrapper_on_track_subscribed_wrapper_on_track_unsubscribed_wrapper_on_data_received_wrapper_on_connected_wrapper_on_disconnected_wrapper)r_   r   s     rK   r   zLiveKitTransportClient.setup   s     "//XX4#5#5#D#D#FG
 	.		,-d.T.TU0		/01Z1Z[(		'()J)JK*		)*4+N+NO%		_%d&D&DE!		[!$"<"<=$		^$T%B%BCs   F Fc                 @   K   | j                          d{    y7 w)zCleanup client resources.N)
disconnectr   s    rK   cleanupzLiveKitTransportClient.cleanup  s     oos   framec                 ^   K   | j                   j                  xs |j                  | _        yw)zStart the client and initialize audio components.

        Args:
            frame: The start frame containing initialization parameters.
        N)r   audio_out_sample_rate_out_sample_rater_   r   s     rK   startzLiveKitTransportClient.start  s%      !% B B aeFaFas   +-r)   r'   r*   r0   )
multiplierminmax)stopwaitc                   K   | j                   4 d{    | j                  r'| xj                  dz  c_        	 ddd      d{    yt        j                  d| j
                          	 | j                  j                  | j                  | j                  t        j                  d             d{    d| _        | xj                  dz  c_        | j                  j                  j                  | _        t        j                  d| j
                          t        j                  | j                   | j"                  j$                        | _        t        j(                  j+                  d| j&                        | _        t        j.                         }t        j0                  j2                  |_        | j                  j                  j7                  | j,                  |       d{    | j8                  j;                          d{    | j=                         }|r9| j>                  s-d| _        | j8                  jA                  |d	          d{    ddd      d{    y7 ]7 .7 7 7 k7 "# tB        $ r+}t        jD                  d
| j
                   d|         d}~ww xY w7 K# 1 d{  7  sw Y   yxY ww)z-Connect to the LiveKit room with retry logic.Nr'   zConnecting to T)auto_subscribe)optionszConnected to zpipecat-audior   zError connecting to : )#r   r   r   r	   infor   r   connectr   r   r"   RoomOptionslocal_participantsidr   AudioSourcer   r   audio_out_channelsr   LocalAudioTrackcreate_audio_trackr   TrackPublishOptionsTrackSourceSOURCE_MICROPHONEsourcepublish_trackr   rm   get_participantsr   rw   r   error)r_   r   participantses       rK   r   zLiveKitTransportClient.connect  sK     ## )	 )	((A-(	)	 )	 )	 KK.(9:;!ii''IIKKOO4@ (   
 #'((A-('+yy'B'B'F'F$mDOO+<=> &)__))4<<+J+J&" %($7$7$J$J#T%7%7%! 113!$!B!Bii11??@Q@QSZ[[[oo22444  $446(J(J9=D6//EElSToVVVM)	 )	 )	 )	* \4 W 3DOO3DBqcJKO)	 )	 )	 )	s   KI0K#J8KI3K"J8.A	I?7I68D5I?-I9.!I?I;A
I?I=I?K*J6+K3K6I?9I?;I?=I??	J3&J..J33J86K8K
>K?K
Kc                   K   | j                   4 d{    | xj                  dz  c_        | j                  r| j                  dkD  r	 ddd      d{    yt        j                  d| j
                          | j                  j                          d{    | j                  j                          d{    d| _        t        j                  d| j
                          | j                  j                          d{    ddd      d{    y7 	7 7 7 g7 7 # 1 d{  7  sw Y   yxY ww)z!Disconnect from the LiveKit room.Nr'   r   zDisconnecting from FDisconnected from )r   r   r   r	   r   r   r   ro   r   r   rn   r   s    rK   r   z!LiveKitTransportClient.disconnectB  s    ## 	4 	4$$)$??d&>&>&B	4 	4 	4 KK-doo->?@//66888))&&(((#DOKK,T__,=>?//11333	4 	4 	4 	4 9( 4	4 	4 	4 	4s   D>DD>2D)	D>DD>?D)D!!D);D#<A
D)D%D)D>D'D>D>!D)#D)%D)'D>)D;/D20D;7D>NdatarA   c                 R  K   | j                   sy	 |r2| j                  j                  j                  |d|g       d{    y| j                  j                  j                  |d       d{    y7 57 # t        $ r"}t        j                  d|        Y d}~yd}~ww xY ww)zSend data to participants in the room.

        Args:
            data: The data bytes to send.
            participant_id: Optional specific participant to send to.
        NT)reliabledestination_identities)r   zError sending data: )r   r   r   publish_datar   r	   r   )r_   r   rA   r   s       rK   	send_dataz LiveKitTransportClient.send_dataR  s      	5ii11>>4@P ?    ii11>>td>SSS	 T 	5LL/s344	5s]   B'.A9 A5 A9 B'*A9 /A70A9 4B'5A9 7A9 9	B$BB'B$$B'digitc                 @  K   | j                   sy|t        vrt        j                  d|        yt        |   }	 | j                  j
                  j                  ||       d{    y7 # t        $ r%}t        j                  d| d|        Y d}~yd}~ww xY ww)zkSend DTMF tone to the room.

        Args:
            digit: The DTMF digit to send (0-9, \*, #).
        NzInvalid DTMF digit: )coder   zError sending DTMF tone r   )	r   DTMF_CODE_MAPr	   warningr   r   publish_dtmfr   r   )r_   r   r   r   s       rK   	send_dtmfz LiveKitTransportClient.send_dtmff  s      %NN1%9:U#	B))--::E:RRR 	BLL3E7"QC@AA	Bs@   8B*A- %A+&A- *B+A- -	B6BBBBaudio_framec                    K   | j                   r| j                  sy	 | j                  j                  |       d{    y7 # t        $ r"}t	        j
                  d|        Y d}~yd}~ww xY ww)zxPublish an audio frame to the room.

        Args:
            audio_frame: The LiveKit audio frame to publish.
        FNTzError publishing audio: )r   r   capture_framer   r	   r   )r_   r   r   s      rK   publish_audioz$LiveKitTransportClient.publish_audioz  sh      d&8&8	$$22;??? @ 	LL3A378	s>   A1A AA  A1A 	A.A)$A1)A..A1c                     | j                   j                  j                         D cg c]  }|j                   c}S c c}w zhGet list of participant IDs in the room.

        Returns:
            List of participant IDs.
        )r   remote_participantsvaluesr   )r_   ps     rK   r   z'LiveKitTransportClient.get_participants  s/      $yy<<CCEF!FFFs   =c                    K   | j                   j                  j                  |      }|r/|j                  |j                  |j
                  |j                  dS i S w)Get metadata for a specific participant.

        Args:
            participant_id: ID of the participant to get metadata for.

        Returns:
            Dictionary containing participant metadata.
        )idnamemetadatais_speaking)r   r   getr   r   r   r   )r_   rA   participants      rK   get_participant_metadataz/LiveKitTransportClient.get_participant_metadata  sX      ii3377G!oo#(('00*66	  	s   AAr   c                 j   K   | j                   j                  j                  |       d{    y7 wzmSet metadata for the local participant.

        Args:
            metadata: Metadata string to set.
        N)r   r   set_metadatar_   r   s     rK   set_participant_metadataz/LiveKitTransportClient.set_participant_metadata  s&      ii))66x@@@s   )313c                    K   | j                   j                  j                  |      }|rI|j                  j	                         D ]+  }|j
                  dk(  s|j                  d       d{    - yy7 w)~Mute a specific participant's audio tracks.

        Args:
            participant_id: ID of the participant to mute.
        audioFNr   r   r   tracksr   kindset_enabledr_   rA   r   tracks       rK   mute_participantz'LiveKitTransportClient.mute_participant  sm      ii3377G$++224 3::(++E2223  3   AA6A6+A4,	A6c                    K   | j                   j                  j                  |      }|rI|j                  j	                         D ]+  }|j
                  dk(  s|j                  d       d{    - yy7 w)Unmute a specific participant's audio tracks.

        Args:
            participant_id: ID of the participant to unmute.
        r  TNr  r  s       rK   unmute_participantz)LiveKitTransportClient.unmute_participant  sm      ii3377G$++224 2::(++D1112  2r	  r   c                 `    | j                   j                  | j                  |      |  d       y)z)Wrapper for participant connected events.z!::_async_on_participant_connectedN)r   create_task_async_on_participant_connectedr_   r   s     rK   r   z8LiveKitTransportClient._on_participant_connected_wrapper  s/    &&00=f56	
rJ   c                 `    | j                   j                  | j                  |      |  d       y)z,Wrapper for participant disconnected events.z$::_async_on_participant_disconnectedN)r   r  "_async_on_participant_disconnectedr  s     rK   r   z;LiveKitTransportClient._on_participant_disconnected_wrapper  s/    &&33K@f89	
rJ   r  publicationc                 d    | j                   j                  | j                  |||      |  d       y)z$Wrapper for track subscribed events.z::_async_on_track_subscribedN)r   r  _async_on_track_subscribedr_   r  r  r   s       rK   r   z3LiveKitTransportClient._on_track_subscribed_wrapper  s5     	&&++E;Lf01	
rJ   c                 d    | j                   j                  | j                  |||      |  d       y)z&Wrapper for track unsubscribed events.z::_async_on_track_unsubscribedN)r   r  _async_on_track_unsubscribedr  s       rK   r   z5LiveKitTransportClient._on_track_unsubscribed_wrapper  s5     	&&--e[+Nf23	
rJ   c                 `    | j                   j                  | j                  |      |  d       y)z!Wrapper for data received events.z::_async_on_data_receivedN)r   r  _async_on_data_receivedr_   r   s     rK   r   z0LiveKitTransportClient._on_data_received_wrapper  s/    &&((.f-.	
rJ   c                 ^    | j                   j                  | j                         |  d       y)zWrapper for connected events.z::_async_on_connectedN)r   r  _async_on_connectedr   s    rK   r   z,LiveKitTransportClient._on_connected_wrapper  s)    &&t'?'?'AdVK`CabrJ   c                 ^    | j                   j                  | j                         |  d       y)z Wrapper for disconnected events.z::_async_on_disconnectedN)r   r  _async_on_disconnectedr   s    rK   r   z/LiveKitTransportClient._on_disconnected_wrapper  s,    &&'')dV3K+L	
rJ   c                 4  K   t        j                  d|j                          | j                  j	                  |j
                         d{    | j                  s5d| _        | j                  j                  |j
                         d{    yy7 F7 w)$Handle participant connected events.zParticipant connected: NT)r	   r   identityr   rp   r   r   rw   r  s     rK   r  z6LiveKitTransportClient._async_on_participant_connected  s|     -k.B.B-CDEoo66{GGG1115D.//==kooNNN 2 	H Os$   ABB?BBBBc                    K   t        j                  d|j                          | j                  j	                  |j
                         d{    t        | j                               dk(  rd| _        yy7 )w)'Handle participant disconnected events.zParticipant disconnected: Nr   F)	r	   r   r"  r   rq   r   lenr   r   r  s     rK   r  z9LiveKitTransportClient._async_on_participant_disconnected  sf     01E1E0FGHoo99+//JJJt$$&'1,16D. - 	Ks   AA9A7*A9c                   K   |j                   t        j                  j                  k(  rt	        j
                  d|j                   d|j                          || j                  |j                  <   t        j                  |      }| j                  j                  | j                  ||j                        |  d       | j                  j                  |j                         d{    y|j                   t        j                  j                  k(  rt	        j
                  d|j                   d|j                          || j                  |j                  <   | j                   j"                  rNt        j$                  |      }| j                  j                  | j'                  ||j                        |  d       | j                  j)                  |j                         d{    yy7 7 	w)zHandle track subscribed events.zAudio track subscribed: z from participant z::_process_audio_streamNzVideo track subscribed: z::_process_video_stream)r  r"   	TrackKind
KIND_AUDIOr	   r   r   r   AudioStreamr   r  _process_audio_streamr   rr   
KIND_VIDEOr   r   video_in_enabledVideoStream_process_video_streamrt   )r_   r  r  r   audio_streamvideo_streams         rK   r  z1LiveKitTransportClient._async_on_track_subscribed  s     ::111KK2599+=OP[P_P_O`ab27D{/??51L****<I&/0 //;;KOOLLLZZ3==333KK2599+=OP[P_P_O`ab27D{/ ||,,"u5""....|[__Mf34 //;;KOOLLL 4 M Ms%   C&G5(G0)D G5)G3*G53G5c                   K   t        j                  d|j                   d|j                          |j                  t
        j                  j                  k(  r.| j                  j                  |j                         d{    y|j                  t
        j                  j                  k(  r.| j                  j                  |j                         d{    yy7 [7 w)z!Handle track unsubscribed events.zTrack unsubscribed: z from N)r	   r   r   r"  r  r"   r'  r(  r   rs   r+  ru   r  s       rK   r  z3LiveKitTransportClient._async_on_track_unsubscribed*  s      	*;??*;6+BVBVAWXY::111//==kooNNNZZ3==333//==kooNNN 4 ONs%   A?C!CAC!CC!C!c                    K   | j                   j                  |j                  |j                  j                         d{    y7 w)Handle data received events.N)r   rv   r   r   r   r  s     rK   r  z.LiveKitTransportClient._async_on_data_received7  s0     oo..tyy$:J:J:N:NOOOs   >A AAc                 T   K   | j                   j                          d{    y7 w)zHandle connected events.N)r   rm   r   s    rK   r  z*LiveKitTransportClient._async_on_connected;  s     oo**,,,s   (&(c                    K   d| _         t        j                  d| j                   d|        | j                  j                          d{    y7 w)zHandle disconnected events.Fr   z
. Reason: N)r   r	   r   r   r   rn   )r_   reasons     rK   r  z-LiveKitTransportClient._async_on_disconnected?  sB     ((9F8LMoo--///s   A
AAAr/  c                    K   t        j                  d|        |2 3 d{   }t        |t        j                        r&| j
                  j                  ||f       d{    It        j                  dt        |              k7 f7 )6 yw)z1Process incoming audio stream from a participant.z0Started processing audio stream for participant N Received unexpected event type: )	r	   r   
isinstancer"   AudioFrameEventr   putr   type)r_   r/  rA   events       rK   r*  z,LiveKitTransportClient._process_audio_streamE       F~FVWX' 	Q 	Q%%!4!45''++UN,CDDD!A$u+OP		QD (7   BBBB;B B
!'BB
BBc                j   K   	 | j                   j                          d{   \  }}||f -7 w)z(Get the next audio frame from the queue.N)r   r   r_   r   rA   s      rK   get_next_audio_framez+LiveKitTransportClient.get_next_audio_frameN  8     *.*;*;*?*?*A$A!E>'' $A   313r0  c                    K   t        j                  d|        |2 3 d{   }t        |t        j                        r&| j
                  j                  ||f       d{    It        j                  dt        |              k7 f7 )6 yw)z1Process incoming video stream from a participant.z0Started processing video stream for participant Nr8  )	r	   r   r9  r"   VideoFrameEventr   r;  r   r<  )r_   r0  rA   r=  s       rK   r.  z,LiveKitTransportClient._process_video_streamT  r>  r?  c                j   K   	 | j                   j                          d{   \  }}||f -7 w)z(Get the next video frame from the queue.N)r   r   rA  s      rK   get_next_video_framez+LiveKitTransportClient.get_next_video_frame]  rC  rD  c                      | j                    dS )z6String representation of the LiveKit transport client.z::LiveKitTransportClient)r   r   s    rK   __str__zLiveKitTransportClient.__str__c  s    &&''?@@rJ   N)>rC   rD   rE   rF   rG   rj   rl   r   propertyrA   r"   r   r   r   r   r   r   r   r$   r%   r&   r   r   rx   r   r   r   
AudioFrameboolr   r   r   dictr   r   r  r  RemoteParticipantr   r   TrackRemoteTrackPublicationr   r   
DataPacketr   r   r   r  r  r  r  r  r  r  r)  r*  rB  r-  r.  rH  rJ  rI   rJ   rK   rz   rz      s   %*%* %* 	%*
 %* $%* %*N $ $ $ chh  D!4 D* b b "1%,<qVX,YZ+ [+Z4 5E 58C= 5(BS B(s~~ $  G$s) GS T &As A
3S 
3
2s 
2
S=R=R 

@U@U 


yy

 //

 **	



yy

 //

 **	


cnn 
c
OAVAV O7CDYDY 7MyyM //M **	M:OyyO //O **	OP#.. P-0Q QY\ Q(Q QY\ Q(ArJ   rz   c                        e Zd ZdZdededef fdZede	e
   fd       Zdef fd	Zdef fd
Zdef fdZdef fdZ fdZdedefdZd Zd Zdej6                  defdZdej<                  defdZ  xZ!S )LiveKitInputTransportzHandles incoming media streams and events from LiveKit rooms.

    Processes incoming audio streams from room participants and forwards them
    as Pipecat frames, including audio resampling and VAD integration.
    	transportclientr~   c                     t        |   |fi | || _        || _        d| _        d| _        |j                  | _        t               | _	        d| _
        y)a  Initialize the LiveKit input transport.

        Args:
            transport: The parent transport instance.
            client: LiveKitTransportClient instance.
            params: Configuration parameters.
            **kwargs: Additional arguments passed to parent class.
        NF)rW   r   
_transport_client_audio_in_task_video_in_taskvad_analyzer_vad_analyzerr   
_resampler_initializedr_   rV  rW  r~   kwargsr`   s        rK   r   zLiveKitInputTransport.__init__o  sW     	*6*#""4:4G4G13 "rJ   r   c                     | j                   S )zzGet the Voice Activity Detection analyzer.

        Returns:
            The VAD analyzer instance if configured.
        )r^  r   s    rK   r]  z"LiveKitInputTransport.vad_analyzer  s     !!!rJ   r   c                 t  K   t         |   |       d{    | j                  ryd| _        | j                  j                  |       d{    | j                  j	                          d{    | j
                  s:| j                  j                  r$| j                  | j                               | _        | j                  s:| j                  j                  r$| j                  | j                               | _
        | j                  |       d{    t        j                  d       y7 7 7 7 !w)zStart the input transport and connect to LiveKit room.

        Args:
            frame: The start frame containing initialization parameters.
        NTzLiveKitInputTransport started)rW   r   r`  rZ  r   r[  r   audio_in_enabledr  _audio_in_task_handlerr\  r,  _video_in_task_handlerset_transport_readyr	   r   r_   r   r`   s     rK   r   zLiveKitInputTransport.start  s      gmE""" ll  '''ll""$$$""t||'D'D"&"2"243N3N3P"QD""t||'D'D"&"2"243N3N3P"QD&&u---34 	# 	($
 	.sF   D8D/6D8D2!D8/D40B$D8D6D82D84D86D8c                 v  K   t         |   |       d{    | j                  j                          d{    | j                  r#| j                  | j                         d{    | j                  r#| j                  | j                         d{    t        j                  d       y7 7 z7 M7  w)zStop the input transport and disconnect from LiveKit room.

        Args:
            frame: The end frame signaling transport shutdown.
        NzLiveKitInputTransport stopped)	rW   r   rZ  r   r[  cancel_taskr\  r	   r   ri  s     rK   r   zLiveKitInputTransport.stop  s      gl5!!!ll%%'''""4#6#6777""4#6#677734 	"'77sC   B9B1!B9B3.B9'B5(.B9B7B93B95B97B9c                   K   t         |   |       d{    | j                  j                          d{    | j                  r9| j
                  j                  r#| j                  | j                         d{    | j                  r;| j
                  j                  r$| j                  | j                         d{    yyy7 7 7 P7 w)zCancel the input transport and disconnect from LiveKit room.

        Args:
            frame: The cancel frame signaling immediate cancellation.
        N)
rW   cancelrZ  r   r[  r   re  rk  r\  r,  ri  s     rK   rm  zLiveKitInputTransport.cancel  s      gnU###ll%%'''4<<#@#@""4#6#67774<<#@#@""4#6#6777 $A	 	$'77sE   CC
!CCAC=C>ACCCCCCr   c                    K   t         |   |       d{    | j                  j                  |       d{    y7 (7 w)zSetup the input transport with shared client setup.

        Args:
            setup: The frame processor setup configuration.
        NrW   r   rZ  r_   r   r`   s     rK   r   zLiveKitInputTransport.setup  <      gmE"""ll  ''' 	#'   A?"AAAAc                    K   t         |           d{    | j                  j                          d{    y7 '7 w)z-Cleanup input transport and shared resources.NrW   r   rY  r_   r`   s    rK   r   zLiveKitInputTransport.cleanup  6     gooo%%''' 	 '   A=!A?AAmessagesenderc                 \   K   t        ||      }| j                  |       d{    y7 w)zPush an application message as an urgent transport frame.

        Args:
            message: The message data to send.
            sender: ID of the message sender.
        rx  rA   N)rN   
push_frame)r_   rx  ry  r   s       rK   push_app_messagez&LiveKitInputTransport.push_app_message  s'      9Y_`ooe$$$s   ",*,c                   K   t        j                  d       | j                  j                         }|2 3 d{   }|s|\  }}| j	                  |       d{   }t        |j                        dk(  rCt        ||j                  |j                  |j                        }| j                  |       d{    7 7 f7 	6 yw)z/Handle incoming audio frames from participants.zAudio input task startedNr   )user_idr  sample_ratenum_channels)r	   r   rZ  rB  !_convert_livekit_audio_to_pipecatr%  r  r   r  r  push_audio_frame)r_   audio_iterator
audio_dataaudio_frame_eventrA   pipecat_audio_frameinput_audio_frames          rK   rf  z,LiveKitInputTransport._audio_in_task_handler  s     ./::< . 	? 	?*4>1!>,0,R,R%- '#
 *001Q6$5*-33 3 ? ?!4!A!A	%! ++,=>>>#	?' ?# !/sP   2CCB>CC CC AC8C9C>C CCCc                   K   t        j                  d       | j                  j                         }|2 3 d{   }|s|\  }}| j	                  |       d{   }t        |j                        dk(  rDt        ||j                  |j                  |j                        }| j                  |       d{    7 7 f7 	6 yw)z/Handle incoming video frames from participants.zVideo input task startedN)video_frame_eventr   )r  imagesizeformat)r	   r   rZ  rH  !_convert_livekit_video_to_pipecatr%  r  r   r  r  push_video_frame)r_   video_iterator
video_datar  rA   pipecat_video_frameinput_video_frames          rK   rg  z,LiveKitInputTransport._video_in_task_handler  s     ./::< . 	? 	?*4>1!>,0,R,R&7 -S - '#
 *001Q6$5*-33,11.55	%! ++,=>>>#	?' ?# !/sP   2CCB?CC CCAC9C:C?CCCCr  c                   K   |j                   }| j                  j                  |j                  j	                         |j
                  | j
                         d{   }t        || j
                  |j                        S 7 &w)z3Convert LiveKit audio frame to Pipecat audio frame.N)r  r  r  )r   r_  resampler   tobytesr  r   r  )r_   r  r   r  s       rK   r  z7LiveKitInputTransport._convert_livekit_audio_to_pipecat
  sw      (--??33$$&(?(?AQAQ
 

 (($11
 	
	
s   ABB'Br  c                    K   |j                   j                  t        j                  j                        }t        |j                  |j                  |j                  fd      }|S w)z3Convert LiveKit video frame to Pipecat video frame.RGB)r  r  r  )	r   convertproto_video_frameVideoBufferTypeRGB24r   r   widthheight)r_   r  	rgb_frameimage_frames       rK   r  z7LiveKitInputTransport._convert_livekit_video_to_pipecat  sY     
 &++334E4U4U4[4[\	#..//9#3#34

 s   A$A&)"rC   rD   rE   rF   r   rz   rj   r   rL  r   r   r]  r   r   r   r   r   rm  r   r   r   r   rG   r}  rf  rg  r"   r:  r   r  rF  r   r  rc   rd   s   @rK   rU  rU  h  s    " " '" 	"6 "h{3 " "5 5,5 58+ 8(!4 ((
%c %3 %?.?.
!$!4!4
	
 .. 
rJ   rU  c                        e Zd ZdZdededef fdZdef fdZ	de
f fdZdef fd	Zd
ef fdZ fdZdeez  fdZdedefdZdefdZdeez  fdZdedej:                  fdZ xZS )LiveKitOutputTransportzHandles outgoing media streams and events to LiveKit rooms.

    Manages sending audio frames and data messages to LiveKit room participants,
    including audio format conversion for LiveKit compatibility.
    rV  rW  r~   c                 P    t        |   |fi | || _        || _        d| _        y)a  Initialize the LiveKit output transport.

        Args:
            transport: The parent transport instance.
            client: LiveKitTransportClient instance.
            params: Configuration parameters.
            **kwargs: Additional arguments passed to parent class.
        FN)rW   r   rY  rZ  r`  ra  s        rK   r   zLiveKitOutputTransport.__init__/  s/     	*6*# "rJ   r   c                 Z  K   t         |   |       d{    | j                  ryd| _        | j                  j                  |       d{    | j                  j	                          d{    | j                  |       d{    t        j                  d       y7 7 W7 77  w)zStart the output transport and connect to LiveKit room.

        Args:
            frame: The start frame containing initialization parameters.
        NTzLiveKitOutputTransport started)rW   r   r`  rZ  r   rh  r	   r   ri  s     rK   r   zLiveKitOutputTransport.startE  s      gmE""" ll  '''ll""$$$&&u---45 	# 	($-sE   B+B#6B+B%!B+/B'0B+B)	B+%B+'B+)B+c                    K   t         |   |       d{    | j                  j                          d{    t	        j
                  d       y7 <7 w)zStop the output transport and disconnect from LiveKit room.

        Args:
            frame: The end frame signaling transport shutdown.
        NzLiveKitOutputTransport stopped)rW   r   rZ  r   r	   r   ri  s     rK   r   zLiveKitOutputTransport.stopW  sG      gl5!!!ll%%'''45 	"'s   AA!AAAAc                    K   t         |   |       d{    | j                  j                          d{    y7 '7 w)zCancel the output transport and disconnect from LiveKit room.

        Args:
            frame: The cancel frame signaling immediate cancellation.
        N)rW   rm  rZ  r   ri  s     rK   rm  zLiveKitOutputTransport.cancela  s:      gnU###ll%%''' 	$'s   A>!AA A Ar   c                    K   t         |   |       d{    | j                  j                  |       d{    y7 (7 w)zSetup the output transport with shared client setup.

        Args:
            setup: The frame processor setup configuration.
        Nro  rp  s     rK   r   zLiveKitOutputTransport.setupj  rq  rr  c                    K   t         |           d{    | j                  j                          d{    y7 '7 w)z.Cleanup output transport and shared resources.Nrt  ru  s    rK   r   zLiveKitOutputTransport.cleanups  rv  rw  c                   K   |j                   }t        |t              rt        j                  |d      }t        |t
        t        f      r=| j                  j                  |j                         |j                         d{    y| j                  j                  |j                                d{    y7 77 w)zySend a transport message to participants.

        Args:
            frame: The transport message frame to send.
        F)ensure_asciiN)rx  r9  rO  jsondumpsr?   rN   rZ  r   encoderA   )r_   r   rx  s      rK   send_messagez#LiveKitOutputTransport.send_messagex  s      --gt$jju=G68`a
 ,,(()95;O;OPPP,,(()9::: Q:s$   BB?B;1B?5B=6B?=B?r   c                    K   | j                  |j                        }| j                  j                  |       d{   S 7 w)zWrite an audio frame to the LiveKit room.

        Args:
            frame: The audio frame to write.

        Returns:
            True if the audio frame was written successfully, False otherwise.
        N)!_convert_pipecat_audio_to_livekitr  rZ  r   )r_   r   livekit_audios      rK   write_audio_framez(LiveKitOutputTransport.write_audio_frame  s7      >>u{{K\\//>>>>s   :AAAc                      y)zLiveKit supports native DTMF via telephone events.

        Returns:
            True, as LiveKit supports native DTMF transmission.
        TrI   r   s    rK   _supports_native_dtmfz,LiveKitOutputTransport._supports_native_dtmf  s     rJ   c                 ~   K   | j                   j                  |j                  j                         d{    y7 w)zUse LiveKit's native publish_dtmf method for telephone events.

        Args:
            frame: The DTMF frame to write.
        N)rZ  r   buttonvaluer   s     rK   _write_dtmf_nativez)LiveKitOutputTransport._write_dtmf_native  s*      ll$$U\\%7%7888s   3=;=pipecat_audioc                     d}t        |      |z  }|| j                  j                  z  }t        j                  || j
                  | j                  j                  |      S )z2Convert Pipecat audio data to LiveKit audio frame.r(   )r   r  r  samples_per_channel)r%  r   r   r"   rM  r  )r_   r  bytes_per_sampletotal_samplesr  s        rK   r  z8LiveKitOutputTransport._convert_pipecat_audio_to_livekit  sZ    M*.>>+t||/N/NN~~((88 3	
 	
rJ   ) rC   rD   rE   rF   r   rz   rj   r   r   r   r   r   r   rm  r   r   r   r   r   r  r   rN  r  r  r   r   r  rx   r"   rM  r  rc   rd   s   @rK   r  r  (  s    " " '" 	",6 6$6 6(+ ((!4 ((
;03TT;&
?-@ 
?T 
?t 9o@U.U 9
u 
 
rJ   r  c                       e Zd ZdZ	 	 	 d*dedededee   dee   dee   f fdZd	efd
Z	d	e
fdZed	efd       ZdefdZd	ee   fdZded	efdZdefdZdefdZdefdZd Zd Zd ZdefdZdefdZdefdZdefdZdefdZdefdZde defd Z!d+d!edee   fd"Z"d+d!edee   fd#Z#d$ Z$d% Z%d& Z&d'efd(Z'defd)Z( xZ)S ),LiveKitTransporta  Transport implementation for LiveKit real-time communication.

    Provides comprehensive LiveKit integration including audio streaming, data
    messaging, participant management, and room event handling for conversational
    AI applications.

    Event handlers available:

    - on_connected: Called when the bot connects to the room.
    - on_disconnected: Called when the bot disconnects from the room.
    - on_before_disconnect: [sync] Called just before the bot disconnects.
    - on_call_state_updated: Called when the call state changes. Args: (state: str)
    - on_first_participant_joined: Called when the first participant joins.
      Args: (participant_id: str)
    - on_participant_connected: Called when a participant connects.
      Args: (participant_id: str)
    - on_participant_disconnected: Called when a participant disconnects.
      Args: (participant_id: str)
    - on_participant_left: Called when a participant leaves.
      Args: (participant_id: str, reason: str)
    - on_audio_track_subscribed: Called when an audio track is subscribed.
      Args: (participant_id: str)
    - on_audio_track_unsubscribed: Called when an audio track is unsubscribed.
      Args: (participant_id: str)
    - on_video_track_subscribed: Called when a video track is subscribed.
      Args: (participant_id: str)
    - on_video_track_unsubscribed: Called when a video track is unsubscribed.
      Args: (participant_id: str)
    - on_data_received: Called when data is received from a participant.
      Args: (data: bytes, participant_id: str)

    Example::

        @transport.event_handler("on_first_participant_joined")
        async def on_first_participant_joined(transport, participant_id):
            await task.queue_frame(TTSSpeakFrame("Hello!"))

        @transport.event_handler("on_participant_disconnected")
        async def on_participant_disconnected(transport, participant_id):
            await task.queue_frame(EndFrame())
    r{   r|   r}   r~   
input_nameoutput_namec                    t         |   ||       t        | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                        }|xs
 t               | _        t!        |||| j                  || j"                        | _        d| _        d| _        | j+                  d       | j+                  d       | j+                  d       | j+                  d       | j+                  d       | j+                  d	       | j+                  d
       | j+                  d       | j+                  d       | j+                  d       | j+                  d       | j+                  d       | j+                  dd       y)a  Initialize the LiveKit transport.

        Args:
            url: LiveKit server URL to connect to.
            token: Authentication token for the room.
            room_name: Name of the LiveKit room to join.
            params: Configuration parameters for the transport.
            input_name: Optional name for the input transport.
            output_name: Optional name for the output transport.
        )r  r  )rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   Nrm   rn   rp   rq   rr   rs   rt   ru   rv   rw   on_participant_lefton_call_state_updatedro   T)sync)rW   r   rl   _on_connected_on_disconnected_on_before_disconnect_on_participant_connected_on_participant_disconnected_on_audio_track_subscribed_on_audio_track_unsubscribed_on_video_track_subscribed_on_video_track_unsubscribed_on_data_received_on_first_participant_joinedrj   r   rz   r   rZ  _input_output_register_event_handler)	r_   r{   r|   r}   r~   r  r  r   r`   s	           rK   r   zLiveKitTransport.__init__  s   & 	JKH$++ 11!%!;!;%)%C%C(,(I(I&*&E&E(,(I(I&*&E&E(,(I(I!33(,(I(I
	 0-	4<<DII
 8<9=$$^4$$%67$$%?@$$%BC$$%@A$$%BC$$%@A$$%BC$$%78$$%BC$$%:;$$%<=$$%;$$GrJ   r   c                     | j                   s2t        | | j                  | j                  | j                        | _         | j                   S )zGet the input transport for receiving media and events.

        Returns:
            The LiveKit input transport instance.
        r   )r  rU  rZ  r   _input_namer   s    rK   inputzLiveKitTransport.input  s:     {{/dllDLLt7G7GDK {{rJ   c                     | j                   s2t        | | j                  | j                  | j                        | _         | j                   S )zGet the output transport for sending media and events.

        Returns:
            The LiveKit output transport instance.
        r  )r  r  rZ  r   _output_namer   s    rK   outputzLiveKitTransport.output$  s:     ||1dllDLLt7H7HDL ||rJ   c                 .    | j                   j                  S )zyGet the participant ID for this transport.

        Returns:
            The participant ID assigned by LiveKit.
        )rZ  rA   r   s    rK   rA   zLiveKitTransport.participant_id0  s     ||***rJ   r   c                    K   | j                   r3| j                   j                  |t        j                         d{    yy7 w)zlSend an audio frame to the LiveKit room.

        Args:
            frame: The audio frame to send.
        N)r  queue_framer   
DOWNSTREAMr   s     rK   
send_audiozLiveKitTransport.send_audio9  s7      <<,,**5.2K2KLLL Ls   :AAAc                 6    | j                   j                         S r   )rZ  r   r   s    rK   r   z!LiveKitTransport.get_participantsB  s     ||,,..rJ   rA   c                 T   K   | j                   j                  |       d{   S 7 w)r   N)rZ  r   r_   rA   s     rK   r   z)LiveKitTransport.get_participant_metadataJ  s#      \\::>JJJJs   (&(r   c                 V   K   | j                   j                  |       d{    y7 wr   )rZ  r   r   s     rK   r   zLiveKitTransport.set_metadataU  s       ll33H===   )')c                 V   K   | j                   j                  |       d{    y7 w)r   N)rZ  r  r  s     rK   r  z!LiveKitTransport.mute_participant]  s       ll++N;;;r  c                 V   K   | j                   j                  |       d{    y7 w)r  N)rZ  r  r  s     rK   r  z#LiveKitTransport.unmute_participante  s       ll--n===r  c                    K   | j                  d       d{    | j                  r,| j                  j                  t                      d{    yy7 =7 w)zHandle room connected events.rm   N)_call_event_handlerr  r|  r   r   s    rK   r  zLiveKitTransport._on_connectedm  sK     &&~666;;++(():)<===  	7=s!   AA6AAAAc                 B   K   | j                  d       d{    y7 w)z Handle room disconnected events.rn   Nr  r   s    rK   r  z!LiveKitTransport._on_disconnecteds  s     &&'8999   c                 B   K   | j                  d       d{    y7 w)z(Handle before disconnection room events.ro   Nr  r   s    rK   r  z&LiveKitTransport._on_before_disconnectw  s     &&'=>>>r  c                    K   | j                  d|       d{    | j                  r,| j                  j                  t                      d{    yy7 =7 w)r!  rp   N)r  r  r|  r   r  s     rK   r  z*LiveKitTransport._on_participant_connected{  sO     &&'A>RRR;;++(()=)?@@@  	S@s!   AA6AAAAc                 ~   K   | j                  d|       d{    | j                  d|d       d{    y7  7 w)r$  rq   Nr  r   r  r  s     rK   r  z-LiveKitTransport._on_participant_disconnected  s@     &&'DnUUU&&'<nn]]] 	V]s   =9=;==c                 4  K   | j                  d|       d{    | j                  j                  j                  j	                  |      }|rG|j
                  j                         D ])  }| j                  j                  |j                  ||       + yy7 }w)z%Handle audio track subscribed events.rr   N)	r  rZ  r   r   r   audio_tracksr   r   r  r_   rA   r   r  s       rK   r  z+LiveKitTransport._on_audio_track_subscribed       &&'BNSSSll'';;??O*77>>@ 99%%{K  	T   BBA>Bc                 D   K   | j                  d|       d{    y7 w)z'Handle audio track unsubscribed events.rs   Nr  r  s     rK   r  z-LiveKitTransport._on_audio_track_unsubscribed       &&'DnUUU     c                 4  K   | j                  d|       d{    | j                  j                  j                  j	                  |      }|rG|j
                  j                         D ])  }| j                  j                  |j                  ||       + yy7 }w)z%Handle video track subscribed events.rt   N)	r  rZ  r   r   r   video_tracksr   r   r  r  s       rK   r  z+LiveKitTransport._on_video_track_subscribed  r  r  c                 D   K   | j                  d|       d{    y7 w)z'Handle video track unsubscribed events.ru   Nr  r  s     rK   r  z-LiveKitTransport._on_video_track_unsubscribed  r  r  r   c                    K   | j                   r2| j                   j                  |j                         |       d{    | j                  d||       d{    y7  7 w)r3  Nrv   )r  r}  decoder  )r_   r   rA   s      rK   r  z"LiveKitTransport._on_data_received  sP     ;;++..t{{}nMMM&&'94PPP NPs!   :A!AA!AA!A!rx  c                    K   | j                   r1t        ||      }| j                   j                  |       d{    yy7 w)zSend a message to participants in the room.

        Args:
            message: The message string to send.
            participant_id: Optional specific participant to send to.
        r{  N)r  r?   r  r_   rx  rA   r   s       rK   r  zLiveKitTransport.send_message  sB      <<6E ,,++E222	  3   8AAAc                    K   | j                   r1t        ||      }| j                   j                  |       d{    yy7 w)zSend an urgent message to participants in the room.

        Args:
            message: The urgent message string to send.
            participant_id: Optional specific participant to send to.
        r{  N)r  rN   r  r  s       rK   send_message_urgentz$LiveKitTransport.send_message_urgent  sB      <<<E ,,++E222	  3r  c                    K   yw)zXHandle room events.

        Args:
            event: The room event to handle.
        NrI   r_   r=  s     rK   on_room_eventzLiveKitTransport.on_room_event        	   c                    K   yw)zfHandle participant events.

        Args:
            event: The participant event to handle.
        NrI   r  s     rK   on_participant_eventz%LiveKitTransport.on_participant_event  r  r  c                    K   yw)zZHandle track events.

        Args:
            event: The track event to handle.
        NrI   r  s     rK   on_track_eventzLiveKitTransport.on_track_event  r  r  statec                 D   K   | j                  d|       d{    y7 w)z Handle call state update events.r  Nr  )r_   r
  s     rK   _on_call_state_updatedz'LiveKitTransport._on_call_state_updated  s     &&'>FFFr  c                 D   K   | j                  d|       d{    y7 w)z'Handle first participant joined events.rw   Nr  r  s     rK   r  z-LiveKitTransport._on_first_participant_joined  r  r  )NNNrK  )*rC   rD   rE   rF   rG   r   rj   r   rU  r  r  r  rL  rA   r   r  r   r   rO  r   r   r  r  r  r  r  r  r  r  r  r  r  rx   r  r  r   r  r  r	  r  r  rc   rd   s   @rK   r  r    s   (^ +/$(%)6H6H 6H 	6H
 '6H SM6H c]6Hp
, 

. 
 + + +M&9 M/$s) /	KS 	KT 	K>3 ><S <>s >>:?Ac A^ ^
s V Vs V VQE Q3 Q3# 3x} 33 3hsm 3G# GV VrJ   r  )FrF   r   r  dataclassesr   typingr   r   r   r   r   logurur	   pydanticr
   pipecat.audio.utilsr   pipecat.audio.vad.vad_analyzerr   pipecat.frames.framesr   r   r   r   r   r   r   r   r   r   r   r   r   r   "pipecat.processors.frame_processorr   r   pipecat.transports.base_inputr   pipecat.transports.base_outputr   !pipecat.transports.base_transportr   r    "pipecat.utils.asyncio.task_managerr!   livekitr"   livekit.rtc._protor#   r  tenacityr$   r%   r&   ModuleNotFoundErrorr   r   r   r   r?   rN   rQ   rg   rj   rl   rz   rU  r  r  rI   rJ   rK   <module>r     s     ! ; ;   7 6     S < > L >,GDD 
	
	
	
	
	
	
	
	
	
		  ))D ) ) )/P ) ) #E  * )Q  *	O 	By B6wA wAt}. }@J
0 J
ZnV} nVG  ,FLL;qc"#FLLZ[
&qc*
++,s   :D! !E&2EE