Skip to content

Commit e5b88f6

Browse files
committed
ruff format
1 parent ca1b56b commit e5b88f6

2 files changed

Lines changed: 22 additions & 32 deletions

File tree

examples/wakeword_agent_dispatch/client.py

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

livekit-rtc/livekit/rtc/participant.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@
2020
import os
2121
import mimetypes
2222
import aiofiles
23-
from typing import TYPE_CHECKING, List, Union, Callable, Dict, Awaitable, Optional, Mapping, cast, TypeVar
23+
from typing import (
24+
TYPE_CHECKING,
25+
List,
26+
Union,
27+
Callable,
28+
Dict,
29+
Awaitable,
30+
Optional,
31+
Mapping,
32+
cast,
33+
TypeVar,
34+
)
2435
from abc import abstractmethod, ABC
2536

2637
from ._ffi_client import FfiClient, FfiHandle
@@ -779,9 +790,7 @@ async def publish_track(
779790

780791
if preconnect_buffer_auto_send_to:
781792
if track.has_preconnect_buffer:
782-
self._setup_preconnect_auto_send(
783-
track, preconnect_buffer_auto_send_to
784-
)
793+
self._setup_preconnect_auto_send(track, preconnect_buffer_auto_send_to)
785794
else:
786795
logger.warning(
787796
"preconnect_buffer_auto_send_to set but no preconnect buffer "
@@ -793,9 +802,7 @@ async def publish_track(
793802
finally:
794803
self._room_queue.unsubscribe(queue)
795804

796-
def _setup_preconnect_auto_send(
797-
self, track: LocalAudioTrack, target_identity: str
798-
) -> None:
805+
def _setup_preconnect_auto_send(self, track: LocalAudioTrack, target_identity: str) -> None:
799806
room = self._room
800807
if room is None:
801808
return

0 commit comments

Comments
 (0)