Skip to content

fix: bound realtime websocket state for long sessions - #3214

Merged
LauraGPT merged 1 commit into
mainfrom
codex/bound-realtime-long-session-state
Jul 13, 2026
Merged

fix: bound realtime websocket state for long sessions#3214
LauraGPT merged 1 commit into
mainfrom
codex/bound-realtime-long-session-state

Conversation

@LauraGPT

Copy link
Copy Markdown
Collaborator

Summary

  • retain only a rolling audio window while keeping absolute session timestamps
  • cap speaker chunk/embedding history and preserve stable speaker IDs with bounded centroids
  • move blocking session work off the asyncio loop while serializing access to shared models
  • release raw audio on finalization, including sub-chunk sessions

Fixes #3101

Validation

  • python3 -m pytest tests/test_realtime_ws_service.py -q (13 passed)
  • real funasr/SciPy/sklearn speaker clustering smoke test (8 chunks, stable speaker 0)
  • synthetic 2-hour, 16 kHz stream: 72,000 frames in 1.640s; retained buffer 80,000 samples / 320,000 bytes; reported duration 7,200,000ms
  • git diff --check
  • python3 -m py_compile examples/industrial_data_pretraining/fun_asr_nano/serve_realtime_ws.py tests/test_realtime_ws_service.py

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@LauraGPT
LauraGPT force-pushed the codex/bound-realtime-long-session-state branch from 1547844 to d51cf16 Compare July 13, 2026 17:36
@LauraGPT
LauraGPT merged commit a53497b into main Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

即時轉錄一段時間後會自行斷線

1 participant