Enable short fadeout when stopping playback to prevent artifacts#314
Merged
Enable short fadeout when stopping playback to prevent artifacts#314
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
yinishi
reviewed
Apr 30, 2025
yinishi
reviewed
Apr 30, 2025
406520b to
385f17f
Compare
yinishi
approved these changes
May 2, 2025
2823c7b to
48546a2
Compare
48546a2 to
0b5268d
Compare
0b5268d to
cec4c28
Compare
d2abe1e to
97ecda2
Compare
1558dc8 to
588917a
Compare
vpicone
approved these changes
May 6, 2025
Contributor
vpicone
left a comment
There was a problem hiding this comment.
Sounds great to me. Can definitely here the elimination of the audio artifact compared to main.
492472a to
3be89e7
Compare
yinishi
pushed a commit
that referenced
this pull request
May 15, 2025
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.
Context
When audio playback is stopped abruptly before the clip reaches its natural endpoint, it often results in a "clicking" sound. This occurs because the audio waveform is interrupted while at a high amplitude, creating a sudden discontinuity. The occurrence of this clicking sound is unpredictable, as it depends on the random point in the waveform at which playback is halted.
This happens frequently when using the voice SDK and the user interrupts the assistant, which requires the client to stop the playback as soon as it receives the
user_interruptionevent.Change
This PR enables introducing a short fadeout when interrupting the assistant, which prevents any clicking sounds or other potential artifacts by stopping the playback always at a point with amplitude set to virtually 0. The fadeout can be called when clearing the buffer in the worklet. The gain manipulation is applied in the worklet itself, which allows this manipulation to occur at the sample level. The alternative of applying it via a GainNode in the main thread was discarded, as it required estimating the fadeout duration by polling the
currentTimeof the audio clip or using asetTimeout.The change is backwards compatible, as it preserves the previous
clearmessage to the worklet, which does still clear the buffer in the worklet without applying a fadeout.Notes
This change introduces a new nomenclature to worklets: when a change to the worklet is merged, we will rename to new version as
audio-worklet-YYYYMMDD.