@@ -52,40 +52,28 @@ def from_env() -> "Config":
5252 api_key = os .getenv ("LIVEKIT_API_KEY" )
5353 api_secret = os .getenv ("LIVEKIT_API_SECRET" )
5454 if not url or not api_key or not api_secret :
55- raise RuntimeError (
56- "LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET must be set"
57- )
55+ raise RuntimeError ("LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET must be set" )
5856
5957 return Config (
6058 url = url ,
6159 api_key = api_key ,
6260 api_secret = api_secret ,
6361 room_name = os .getenv ("LIVEKIT_ROOM" , "wakeword-preconnect" ),
6462 agent_name = os .getenv ("LIVEKIT_AGENT_NAME" , "test-agent" ),
65- wakeword_model = Path (
66- os .getenv ("LIVEKIT_WAKEWORD_MODEL" , "./models/hey_livekit.onnx" )
67- ),
63+ wakeword_model = Path (os .getenv ("LIVEKIT_WAKEWORD_MODEL" , "./models/hey_livekit.onnx" )),
6864 wakeword_name = os .getenv ("LIVEKIT_WAKEWORD_NAME" ),
6965 wakeword_threshold = float (os .getenv ("LIVEKIT_WAKEWORD_THRESHOLD" , "0.5" )),
70- wakeword_preroll_seconds = float (
71- os .getenv ("LIVEKIT_WAKEWORD_PREROLL_SECONDS" , "2.0" )
72- ),
73- preconnect_buffer_seconds = float (
74- os .getenv ("LIVEKIT_PRECONNECT_BUFFER_SECONDS" , "10.0" )
75- ),
66+ wakeword_preroll_seconds = float (os .getenv ("LIVEKIT_WAKEWORD_PREROLL_SECONDS" , "2.0" )),
67+ preconnect_buffer_seconds = float (os .getenv ("LIVEKIT_PRECONNECT_BUFFER_SECONDS" , "10.0" )),
7668 preconnect_debug_wav = (
7769 Path (debug_wav ).expanduser ()
7870 if (debug_wav := os .getenv ("LIVEKIT_PRECONNECT_DEBUG_WAV" ))
7971 else None
8072 ),
8173 agent_metadata = os .getenv ("LIVEKIT_AGENT_METADATA" , "" ),
8274 agent_wait_timeout = float (os .getenv ("LIVEKIT_AGENT_WAIT_TIMEOUT" , "30.0" )),
83- audio_input_device = Config ._optional_int_from_env (
84- "LIVEKIT_AUDIO_INPUT_DEVICE"
85- ),
86- audio_output_device = Config ._optional_int_from_env (
87- "LIVEKIT_AUDIO_OUTPUT_DEVICE"
88- ),
75+ audio_input_device = Config ._optional_int_from_env ("LIVEKIT_AUDIO_INPUT_DEVICE" ),
76+ audio_output_device = Config ._optional_int_from_env ("LIVEKIT_AUDIO_OUTPUT_DEVICE" ),
8977 )
9078
9179 @staticmethod
@@ -501,10 +489,7 @@ def _on_participant_disconnected(participant: rtc.RemoteParticipant) -> None:
501489 if participant .kind != rtc .ParticipantKind .PARTICIPANT_KIND_AGENT :
502490 return
503491
504- if (
505- state .mode == ClientMode .IN_SESSION
506- and state .agent_identity == participant .identity
507- ):
492+ if state .mode == ClientMode .IN_SESSION and state .agent_identity == participant .identity :
508493 logger .info ("agent participant %s disconnected" , participant .identity )
509494 _reset_to_idle ("agent session ended" )
510495
@@ -670,9 +655,7 @@ def _on_transcription_stream(
670655 reader : rtc .TextStreamReader ,
671656 participant_identity : str ,
672657 ) -> None :
673- _create_background_task (
674- _log_transcription_stream (reader , participant_identity )
675- )
658+ _create_background_task (_log_transcription_stream (reader , participant_identity ))
676659
677660 def _maybe_play_agent_track (
678661 track : rtc .Track ,
0 commit comments