Skip to content

Commit 1f00c24

Browse files
committed
dont process every audio frame for meter ui
1 parent 29f79f6 commit 1f00c24

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

examples/local_audio/full_duplex.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,16 @@ def on_track_unsubscribed(
9292
# Monitor microphone dB levels
9393
async def monitor_mic_db():
9494
mic_stream = rtc.AudioStream(track, sample_rate=48000, num_channels=1)
95+
frame_count = 0
96+
sample_interval = 5 # Process every 5th frame to reduce load
97+
9598
try:
9699
async for frame_event in mic_stream:
100+
# Skip frames to reduce processing load
101+
frame_count += 1
102+
if frame_count % sample_interval != 0:
103+
continue
104+
97105
frame = frame_event.frame
98106
# Convert frame data to list of samples
99107
samples = list(frame.data)

0 commit comments

Comments
 (0)