`_ParticipantAudioInputStream` 补静音帧时`data` 长度未乘声道数,多声道配置下抛`ValueError`
Maintainers usually reply within 1 day
A pull request for this has already been merged.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- audio-video-rtc, backend
Research direction
Read livekit/agents/voice/room_io/_input.py, especially lines 390–399 in _ParticipantAudioInputStream._forward_task, and check how the silence frame size is calculated against num_channels. Confirm the expected byte length is num_channels × samples_per_channel × 2; done when the frame can be created without ValueError for multichannel input.
Written by the indexing model from the issue text.
Description
Bug Description
- File :
livekit/agents/voice/room_io/_input.py - Lines : 390–399(
_ParticipantAudioInputStream._forward_task方法尾部) - Package : livekit-agents(Python SDK)
Root Cause
当远端音频 track 断流、super()._forward_task() 主循环退出后,子类会补一帧 0.5 秒静音(让下游 VAD/STT 能正确检测到停顿)。这帧的字节数据手工构造时 只按"每样本 2 字节"计算,却漏乘了num_channels :
Expected Behavior
- Expected : 无论
num_channels为多少,AudioFrame的data长度都应为num_channels × samples_per_channel × 2 - Actual : data 长度始终为
samples_per_channel × 2,多声道下触发构造函数校验失败
Reproduction Steps
- 配置`AgentSession` 的`RoomIO` 输入音频为多声道(`num_channels=2` 或更高)——比如`RoomInputOptions(num_channels=2)` 或自定义`VoicePipeline` 里`input_audio_options.num_channels = 2`
- 正常跑通一次对话,让远端 participant 断开 / unmute 停止发布音频
- 触发`_on_track_unsubscribed` →`_close_stream` → 新建 stream 并重启`_forward_task` (或 participant 直接断连,主循环自然结束)
- 立刻抛出`ValueError: data length must be >= num_channels * samples_per_channel * sizeof(int16)`
Operating System
Windows11
Models Used
No response
Package Versions
livekit-agents=1.8.0
Session/Room/Call IDs
No response
Proposed Solution
Additional Context
No response
Screenshots and Recordings
No response
- Dominant language
- Python
- Stars
- 14.6k
- Forks
- 3.9k
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 193
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from livekit/agents
-
Assistant markup is stripped from chat history when expressive mode is offPossibly taken @ShivamSharma43 claimed this 14 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hostsMay be free again @AbarnaaSree claimed this 54 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
livekit/agents#7022 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Soniox and simplismart STT detect a dead websocket and reconnect into it forever instead of failing overPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
livekit/agents#8031 · 1 comment ·
Maintainers usually reply within 1 day
-
Agent stays "speaking" forever when the avatar participant leaves mid-replyPossibly taken @regalmoix claimed this 1 day ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 54/100
Maintainers usually reply within 1 day
Similar issues
-
resource-submission validation-passed
Difficulty 1/5 Under an hour Newbie friendliness 88/100
hesreallyhim/awesome-claude-code#3214 · 1 comment ·
Maintainers usually reply within 1 day
-
room-commons replace accepts an empty old string and silently prepends the new text to the pageOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
doobidoo/mcp-memory-service#1650 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ml-explore/mlx-lm#2002 ·
Maintainers usually reply within 2 days