Closed
Fix G.722 ADPCM state reset between TTS chunks causing robotic audio#47
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #47 +/- ##
==========================================
+ Coverage 94.25% 94.36% +0.10%
==========================================
Files 24 24
Lines 1759 1793 +34
==========================================
+ Hits 1658 1692 +34
Misses 101 101 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
…t_chunk Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix G.722 sound issue during echo call
Fix G.722 ADPCM state reset between TTS chunks causing robotic audio
Mar 16, 2026
Owner
|
That wasn't it 👎 |
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.
G.722 TTS output sounded robotic because each
send_rtp_audio()call created a freshav.AudioCodecContext, resetting the ADPCM predictor at every chunk boundary. The receiver decoded a series of independent ADPCM streams rather than one continuous one.Changes
voip/codecs/base.py: AddPayloadEncoderprotocol,PerPacketEncoder(stateless delegate tocodec.packetize), andRTPCodec.create_encoder()factory — mirrors the existing decoder patternvoip/codecs/g722.py: AddG722Encoderdataclass with a persistentav.AudioCodecContextthat survives acrosspacketize()calls; addG722.create_encoder(). Encoding is eager (not lazy generator) so ADPCM state and PTS advance immediately on each callvoip/audio.py: Addpayload_encoder: PayloadEncodertoAudioCall, initialized in__post_init__viacodec.create_encoder(), used insend_rtp_audio()replacingself.codec.packetize()docs/codecs.md: DocumentG722Encoder,PayloadEncoder,PerPacketEncoderOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.