feat(long): opt-in --polish seam smoothing for long-form#1
Open
sb1992 wants to merge 3 commits into
Open
Conversation
added 3 commits
June 14, 2026 22:47
trim_silence (kill dead air) + release_fade (let the last word taper) + boundary_loudness_match (onset matched to prev chunk's tail, not just a global average) + assemble_polished (full recipe). 7 CPU tests.
synthesize_long(polish=True) picks drift-safe defaults (max_seconds 25, gap 250 when unset), trims each chunk, and assembles via assemble_polished (release fade + boundary loudness match + normalize). polish=False resolves to 40/80 + plain assemble_chunks — existing behaviour is byte-identical. CLI: --polish/--release-ms.
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.
Opt-in seam polishing for long-form (
--polish)Independently-generated long-form chunks join with a small audible discontinuity:
the model drifts slightly over a long generation so chunk endings can sound a touch
abrupt, and loudness can step at the join. This adds an opt-in seam recipe that
smooths both —
--polishis off by default, so existingsynthesize_long/--longbehaviour is byte-identical.What it does (when
polish=True)max_secondsto 25s (under the model's ~30sprosody-drift knee) when unset.
trim_silence— drops per-chunk leading/trailing silence (also kills thedead air a no-EOS chunk would otherwise leave).
release_fade— a longer per-chunk end taper so the last word settlesinstead of stopping at full energy.
boundary_loudness_match— global RMS match plus a local onset ramp thatmatches each chunk's start to the previous chunk's tail (not just a global
average), removing the "next word louder" step.
assemble_polished— release fade → boundary match → gap → peak-normalize.Surface
src/zonos2_mlx/seam_polish.py(no mlx / torch).synthesize_long(..., polish=False, release_ms=200)— opt-in;polish=Falseresolves to the prior 40s / 80ms defaults + plain
assemble_chunks.--polish,--release-ms;--max-seconds/--gap-msnow default toNoneand resolve per-mode (40/80 normally, 25/250 with--polish).Tests / validation
tests/test_seam_polish.py); full CPU suite green(45 passed), ruff clean.
--polishpath: 2 chunks → finite, normalized.Context
This is the validated DSP ceiling for ZONOS2 long-form. An isolated experiment
showed the model rejects audio-prefix continuation (it rambles — it was never
trained to continue from prior audio, unlike Zonos v0.1), so cross-chunk prosody
continuity isn't available without a different model or fine-tuning. This PR makes
the independent-chunk seams as clean as DSP allows.