fix: bound realtime websocket state for long sessions - #3214
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces memory optimizations and performance improvements to the realtime ASR service, including bounding the speaker tracker's history with a deque, implementing audio buffer compaction to prevent memory leaks, and running blocking operations off the main event loop. A correctness issue was identified in the speaker tracker's finalization logic where sentences straddling the history boundary can lead to incorrect speaker assignments; a fix is suggested to split these sentences at the boundary.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
1547844 to
d51cf16
Compare
Summary
Fixes #3101
Validation
python3 -m pytest tests/test_realtime_ws_service.py -q(13 passed)funasr/SciPy/sklearn speaker clustering smoke test (8chunks, stable speaker0)72,000frames in1.640s; retained buffer80,000samples /320,000bytes; reported duration7,200,000msgit diff --checkpython3 -m py_compile examples/industrial_data_pretraining/fun_asr_nano/serve_realtime_ws.py tests/test_realtime_ws_service.py