Skip to content

FIX Avoid blocking WAV reads in realtime target - #2305

Open
romanlutz wants to merge 1 commit into
microsoft:mainfrom
romanlutz:romanlutz-daily-reference-maintainability-audit
Open

FIX Avoid blocking WAV reads in realtime target#2305
romanlutz wants to merge 1 commit into
microsoft:mainfrom
romanlutz:romanlutz-daily-reference-maintainability-audit

Conversation

@romanlutz

Copy link
Copy Markdown
Contributor

Description

RealtimeTarget.send_audio_async performed synchronous wave.open() and readframes() calls on the event loop, which could stall concurrent realtime audio requests.

This moves WAV loading into a synchronous helper executed with asyncio.to_thread. The audio bytes and WAV metadata continue through the existing API payload and output-saving path unchanged.

Tests and Documentation

  • Added a unit test that verifies WAV loading is offloaded and preserves the base64 payload, channel count, sample width, and frame rate.
  • tests/unit/prompt_target/target/test_realtime_target.py: 46 passed.
  • Ruff, formatting, async-suffix, type checking, pre-commit hooks, and git diff --check passed.
  • Documentation is not applicable because this is an internal event-loop reliability fix with no API or behavior change.

Move WAV loading to asyncio.to_thread so realtime audio sends do not block the event loop. Add coverage for the offloaded read and preserved payload metadata.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1c85c49c-2d6c-4050-b3e3-ce085c97c5ec
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.

2 participants