Add DiffSinger variance local pitch patch#2176
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an optional (default-off) DiffSinger “local variance patch” behavior so that when a user edits pitch, the variance model still runs normally but only the pitch-changed frame ranges are merged into the previous variance result (with a short crossfade), keeping unchanged regions stable and closer to user expectation. The option is exposed in Preferences and is only enabled/usable when DiffSinger Tensor Cache is enabled.
Changes:
- Added a new preference/UI toggle:
DiffSingerVarianceLocalPitchPatch(defaultfalse), gated byDiffSingerTensorCache. - Implemented
DiffSingerVariancePatchhelper to detect pitch-changed ranges and blend variance outputs locally with crossfades and safe fallback behavior. - Integrated patch-state caching and merge application into
DsVariance.Process, plus added unit tests andInternalsVisibleTofor test access.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| OpenUtau.Core/DiffSinger/DiffSingerVariance.cs | Computes a patch key (excluding pitch), caches previous state per phrase, and conditionally applies local merge after variance inference. |
| OpenUtau.Core/DiffSinger/DiffSingerVariancePatch.cs | New internal helper implementing pitch-diff range detection, weight building, blending, cloning, and metadata-compatibility fallback. |
| OpenUtau.Core/Util/Preferences.cs | Adds DiffSingerVarianceLocalPitchPatch preference with default false. |
| OpenUtau/ViewModels/PreferencesViewModel.cs | Binds the new preference into the VM and persists it on change. |
| OpenUtau/Views/PreferencesDialog.axaml | Adds the new toggle to the DiffSinger section; disables it when tensor cache is off. |
| OpenUtau/Strings/Strings.axaml | Adds the English resource string for the new toggle label. |
| OpenUtau.Core/Properties/AssemblyInfo.cs | Adds InternalsVisibleTo("OpenUtau.Test") to allow unit tests to access internal patch helpers. |
| OpenUtau.Test/Core/DiffSinger/DiffSingerVariancePatchTest.cs | New tests for changed-range grouping, unchanged-pitch preservation, blending behavior, and metadata mismatch fallback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
错误提交,已回滚 |
|
English description: DiffSinger variance local pitch patchWhen users edit pitch, the DiffSinger variance model re-generates the full variance output (energy, breathiness, voicing, tension). Because variance prediction has inherent randomness or global coupling, unedited pitch regions can also shift, deviating from user expectations. This PR adds an opt-in option (`DiffSingerVarianceLocalPitchPatch = false` by default) that blends only the changed pitch regions' new variance output into the previous result, leaving unchanged regions intact. How it works
Configuration
Files (8 files, +272 / -13)
|

解决的问题
原始行为中,用户修改 pitch 后,DiffSinger variance model 会重新生成整段 variance 曲线。由于 variance model 输出存在一定随机性或全局联动,未被用户修改的 pitch 区域也可能发生变化,这会偏离用户预期。
本改动提供一个默认关闭的新选项:只在用户开启后,对 pitch 发生变化的区域应用新的 variance 输出,未变化区域保留上一次结果。
核心逻辑
开关与约束
新选项默认关闭:DiffSingerVarianceLocalPitchPatch = false
该功能依赖 DiffSinger Tensor Cache。
当 DiffSingerTensorCache 未开启时:
这样可以避免在无缓存状态下引入不稳定行为。
改动文件
OpenUtau.Core/DiffSinger/DiffSingerVariance.cs
OpenUtau.Core/DiffSinger/DiffSingerVariancePatch.cs
OpenUtau.Core/Util/Preferences.cs
OpenUtau/ViewModels/PreferencesViewModel.cs
OpenUtau/Views/PreferencesDialog.axaml
OpenUtau/Strings/Strings.axaml
OpenUtau.Core/Properties/AssemblyInfo.cs
OpenUtau.Test/Core/DiffSinger/DiffSingerVariancePatchTest.cs