Skip to content

Commit e0e99ae

Browse files
committed
add example script to list audio devices
1 parent 8e9dc24 commit e0e99ae

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from livekit.rtc import MediaDevices
2+
3+
4+
def main():
5+
# Create a MediaDevices instance
6+
devices = MediaDevices()
7+
8+
# Get default devices
9+
default_input_idx = devices.default_input_device()
10+
default_output_idx = devices.default_output_device()
11+
12+
# List input devices
13+
print("=== Input Devices ===")
14+
input_devices = devices.list_input_devices()
15+
if not input_devices:
16+
print("No input devices found")
17+
else:
18+
for dev in input_devices:
19+
default_marker = " (default)" if dev["index"] == default_input_idx else ""
20+
print(
21+
f" [{dev['index']}] {dev['name']}{default_marker} - "
22+
f"{dev['max_input_channels']} channels @ {dev['default_samplerate']} Hz"
23+
)
24+
25+
print()
26+
27+
# List output devices
28+
print("=== Output Devices ===")
29+
output_devices = devices.list_output_devices()
30+
if not output_devices:
31+
print("No output devices found")
32+
else:
33+
for dev in output_devices:
34+
default_marker = " (default)" if dev["index"] == default_output_idx else ""
35+
print(
36+
f" [{dev['index']}] {dev['name']}{default_marker} - "
37+
f"{dev['max_output_channels']} channels @ {dev['default_samplerate']} Hz"
38+
)
39+
40+
41+
if __name__ == "__main__":
42+
main()
43+

0 commit comments

Comments
 (0)