Fix choppy/distorted audio to live caller

- Mute host mic forwarding while TTS is streaming to prevent interleaving
  both audio sources into the same playback buffer
- Replace nearest-neighbor downsampling with box-filter averaging on both
  server (host mic) and browser (caller mic) for anti-aliased resampling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 17:01:33 -07:00
parent d4e25ceb88
commit d583b48af0
5 changed files with 18 additions and 8 deletions

View File

@@ -880,6 +880,9 @@ async def _host_audio_sender():
"""Persistent task that drains audio queue and sends to callers"""
while True:
pcm_bytes = await _host_audio_queue.get()
# Skip host mic audio while TTS is streaming to avoid interleaving
if caller_service.streaming_tts:
continue
for caller_id in list(caller_service.active_calls.keys()):
try:
await caller_service.send_audio_to_caller(caller_id, pcm_bytes, 16000)