Skip to content

Commit 356d5c0

Browse files
Copilotcloudwebrtc
andauthored
Fix ruff formatting issues
Agent-Logs-Url: https://github.com/livekit/python-sdks/sessions/df3730e3-6da1-4dbf-a628-b5f7d511886f Co-authored-by: cloudwebrtc <17733746+cloudwebrtc@users.noreply.github.com>
1 parent f2d2da4 commit 356d5c0

4 files changed

Lines changed: 11 additions & 28 deletions

File tree

examples/basic_room.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import struct
4949
import wave
5050
from signal import SIGINT, SIGTERM
51-
from typing import Optional, Union
51+
from typing import Optional
5252

5353
from livekit import api, rtc
5454

@@ -100,8 +100,7 @@ def parse_args() -> argparse.Namespace:
100100
"--speaker-id",
101101
type=str,
102102
metavar="DEVICE_ID",
103-
help="Select speaker by device ID (from --list-devices). "
104-
"Only used with --platform-audio.",
103+
help="Select speaker by device ID (from --list-devices). Only used with --platform-audio.",
105104
)
106105

107106
return parser.parse_args()
@@ -172,9 +171,7 @@ def load_wav_file(path: str) -> tuple[bytes, int, int, int]:
172171
return frames, sample_rate, channels, bits_per_sample
173172

174173

175-
async def publish_wav_file(
176-
room: rtc.Room, wav_path: str, running: asyncio.Event
177-
) -> None:
174+
async def publish_wav_file(room: rtc.Room, wav_path: str, running: asyncio.Event) -> None:
178175
"""Publish audio from a WAV file using synthetic mode (AudioSource).
179176
180177
This demonstrates synthetic mode where you manually push audio frames.
@@ -274,9 +271,7 @@ def on_track_subscribed(
274271
publication: rtc.RemoteTrackPublication,
275272
participant: rtc.RemoteParticipant,
276273
) -> None:
277-
logging.info(
278-
f"Track subscribed: {track.kind} from {participant.identity}"
279-
)
274+
logging.info(f"Track subscribed: {track.kind} from {participant.identity}")
280275
if track.kind == rtc.TrackKind.KIND_AUDIO:
281276
# When using PlatformAudio, received audio is automatically played
282277
# through the selected speaker. No manual handling needed.

examples/local_audio/full_duplex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
try:
2929
from dotenv import find_dotenv, load_dotenv
30+
3031
HAS_DOTENV = True
3132
except ImportError:
3233
HAS_DOTENV = False

examples/local_audio/publish_mic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
try:
2323
from dotenv import find_dotenv, load_dotenv
24+
2425
HAS_DOTENV = True
2526
except ImportError:
2627
HAS_DOTENV = False

livekit-rtc/livekit/rtc/platform_audio.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,7 @@ def recording_devices(self) -> List[AudioDeviceInfo]:
231231
f"Failed to enumerate recording devices: {resp.get_audio_devices.error}"
232232
)
233233

234-
return [
235-
AudioDeviceInfo._from_proto(d)
236-
for d in resp.get_audio_devices.recording_devices
237-
]
234+
return [AudioDeviceInfo._from_proto(d) for d in resp.get_audio_devices.recording_devices]
238235

239236
def playout_devices(self) -> List[AudioDeviceInfo]:
240237
"""Get available playout devices (speakers/headphones).
@@ -255,10 +252,7 @@ def playout_devices(self) -> List[AudioDeviceInfo]:
255252
f"Failed to enumerate playout devices: {resp.get_audio_devices.error}"
256253
)
257254

258-
return [
259-
AudioDeviceInfo._from_proto(d)
260-
for d in resp.get_audio_devices.playout_devices
261-
]
255+
return [AudioDeviceInfo._from_proto(d) for d in resp.get_audio_devices.playout_devices]
262256

263257
def set_recording_device(self, device_id: str) -> None:
264258
"""Select the recording device (microphone) to use.
@@ -279,10 +273,7 @@ def set_recording_device(self, device_id: str) -> None:
279273

280274
resp = FfiClient.instance.request(req)
281275

282-
if (
283-
resp.set_recording_device.HasField("error")
284-
and resp.set_recording_device.error
285-
):
276+
if resp.set_recording_device.HasField("error") and resp.set_recording_device.error:
286277
raise PlatformAudioError(
287278
f"Failed to set recording device: {resp.set_recording_device.error}"
288279
)
@@ -306,10 +297,7 @@ def set_playout_device(self, device_id: str) -> None:
306297

307298
resp = FfiClient.instance.request(req)
308299

309-
if (
310-
resp.set_playout_device.HasField("error")
311-
and resp.set_playout_device.error
312-
):
300+
if resp.set_playout_device.HasField("error") and resp.set_playout_device.error:
313301
raise PlatformAudioError(
314302
f"Failed to set playout device: {resp.set_playout_device.error}"
315303
)
@@ -349,9 +337,7 @@ def create_audio_source(
349337
options = PlatformAudioOptions()
350338

351339
req = proto_ffi.FfiRequest()
352-
req.new_audio_source.type = (
353-
proto_audio_frame.AudioSourceType.AUDIO_SOURCE_PLATFORM
354-
)
340+
req.new_audio_source.type = proto_audio_frame.AudioSourceType.AUDIO_SOURCE_PLATFORM
355341
req.new_audio_source.platform_audio_handle = self._ffi_handle.handle
356342
req.new_audio_source.options.CopyFrom(options._to_proto())
357343
# For platform audio, the ADM determines the actual sample rate and channels.

0 commit comments

Comments
 (0)