You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+92Lines changed: 92 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,6 +173,98 @@ except Exception as e:
173
173
174
174
You may find it useful to adjust the `response_timeout` parameter, which indicates the amount of time you will wait for a response. We recommend keeping this value as low as possible while still satisfying the constraints of your application.
175
175
176
+
## Using local media devices
177
+
178
+
The `MediaDevices` class provides a high-level interface for working with local audio input (microphone) and output (speakers) devices. It's built on top of the `sounddevice` library and integrates seamlessly with LiveKit's audio processing features. In order to use `MediaDevices`, you must have the `sounddevice` library installed in your local Python environment, if it's not available, `MediaDevices` will not work.
179
+
180
+
### Capturing microphone input
181
+
182
+
```python
183
+
from livekit import rtc
184
+
185
+
# Create a MediaDevices instance
186
+
devices = rtc.MediaDevices()
187
+
188
+
# Open the default microphone with audio processing enabled
189
+
mic = devices.open_input(
190
+
enable_aec=True, # Acoustic Echo Cancellation
191
+
noise_suppression=True, # Noise suppression
192
+
high_pass_filter=True, # High-pass filter
193
+
auto_gain_control=True# Automatic gain control
194
+
)
195
+
196
+
# Use the audio source to create a track and publish it
For full duplex audio with echo cancellation, open the input device first (with AEC enabled), then open the output device. The output player will automatically feed the APM's reverse stream for effective echo cancellation:
226
+
227
+
```python
228
+
devices = rtc.MediaDevices()
229
+
230
+
# Open microphone with AEC
231
+
mic = devices.open_input(enable_aec=True)
232
+
233
+
# Open speakers - automatically uses the mic's APM for echo cancellation
0 commit comments