ensure failing audio filter init doesn't degrade audio quality#1270
Merged
Conversation
lukasIO
requested review from
MaxHeimbrock,
alan-george-lk,
stephen-derosa and
xianshijing-lk
as code owners
July 21, 2026 09:12
Contributor
Changeset ✓This PR includes a changeset covering all affected packages:
|
theomonnom
approved these changes
Jul 21, 2026
Ensure that initializing a failing audio filter does not degrade audio quality as reported in issue #1270.
xianshijing-lk
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a noise-cancellation filter is requested and the plugin supports
separate rates (v2), the WebRTC sink is created at the codec's native rate
on the assumption that the filter will resample to the requested output
rate. If the filter session fails to initialize, the code fell back to a
plain native stream reusing that codec-rate sink — so codec-rate audio
was forwarded downstream mislabeled as the output rate.
Whenever the codec rate differs from the requested output rate (e.g. a SIP
telephony call, or any track where STT asks for a lower rate than the codec),
this dilates the audio in time: on a failed init we observed STT
transcription_delayjump from ~0.3–0.5s to ~5.5s, with the agent respondingseconds late. Removing the NC option restored baseline latency, because
without the option the sink is already created at the output rate.
Fix
Decide the sink's rate based on whether a filter session actually exists:
run at the codec rate only when a live filter is there to resample it,
otherwise run directly at the requested output rate. A failed (or absent)
filter now degrades to clean, correctly-rated native audio — identical to the
no-option path.
Applied to both
FfiAudioStream::from_trackandfrom_participant.Notes
given filter session fails to initialize.
livekit-ffibuilds clean (no new warnings). Runtime checkpending — a SIP call with the option set should return
transcription_delayto baseline with no pitch/speed shift.