From c5aea09aefc462e28c5e38b73e633e127de1c58c Mon Sep 17 00:00:00 2001 From: Kakaru <97896816+KakaruHayate@users.noreply.github.com> Date: Tue, 16 Jun 2026 02:34:38 +0800 Subject: [PATCH] Modified the color scheme of the timeline, timecode, and scrollbar in the UI. Cap DiffSinger vocoder num_mel_bins at 255 (#2198) --- OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs | 13 +++++++++++++ OpenUtau.Core/DiffSinger/DiffSingerVocoder.cs | 18 ++++++++++++++++++ OpenUtau/Colors/Brushes.axaml | 4 ++++ OpenUtau/Colors/DarkTheme.axaml | 7 +++++-- OpenUtau/Colors/LightTheme.axaml | 5 ++++- OpenUtau/Controls/PianoRoll.axaml | 4 +++- OpenUtau/Views/MainWindow.axaml | 5 ++++- 7 files changed, 51 insertions(+), 5 deletions(-) diff --git a/OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs b/OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs index 7844eea55..69d973789 100644 --- a/OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs +++ b/OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs @@ -149,6 +149,19 @@ float[] InvokeDiffsinger(RenderPhrase phrase, double depth, int steps, Cancellat var vocoder = singer.getVocoder(); //mel specification validity checks + //num_mel_bins must be a sane vocoder value. This is a hard-coded + //upper bound (see DsVocoderConfig.MaxMelBins): voicebank authors + //cannot override it. Not checking this lets a malformed vocoder + //smuggle in a non-vocoder onnx model that requires an unusually + //large mel tensor for inputs. + if (vocoder.num_mel_bins < 1 || vocoder.num_mel_bins > DsVocoderConfig.MaxMelBins) { + throw new Exception( + $"Vocoder num_mel_bins must be between 1 and {DsVocoderConfig.MaxMelBins}, but got {vocoder.num_mel_bins}"); + } + if (singer.dsConfig.num_mel_bins < 1 || singer.dsConfig.num_mel_bins > DsVocoderConfig.MaxMelBins) { + throw new Exception( + $"Acoustic model num_mel_bins must be between 1 and {DsVocoderConfig.MaxMelBins}, but got {singer.dsConfig.num_mel_bins}"); + } //mel base must be 10 or e if (vocoder.mel_base != "10" && vocoder.mel_base != "e") { throw new Exception( diff --git a/OpenUtau.Core/DiffSinger/DiffSingerVocoder.cs b/OpenUtau.Core/DiffSinger/DiffSingerVocoder.cs index 422daabf7..ceffed2b5 100644 --- a/OpenUtau.Core/DiffSinger/DiffSingerVocoder.cs +++ b/OpenUtau.Core/DiffSinger/DiffSingerVocoder.cs @@ -38,6 +38,15 @@ public DsVocoder(string location) { true, new string[] { Path.GetFileName(location), "https://github.com/xunmengshe/OpenUtau/wiki/Vocoders" }); } + if (config.num_mel_bins < 1 || config.num_mel_bins > DsVocoderConfig.MaxMelBins) { + throw new MessageCustomizableException( + $"Invalid num_mel_bins in \"{Path.Combine(location, "vocoder.yaml")}\"", + $"", + new Exception( + $"num_mel_bins must be between 1 and {DsVocoderConfig.MaxMelBins}, got {config.num_mel_bins}"), + true, + new string[] { Path.GetFileName(location), "https://github.com/xunmengshe/OpenUtau/wiki/Vocoders" }); + } hash = XXH64.DigestOf(model); session = Onnx.getInferenceSession(model); } @@ -66,6 +75,15 @@ public void Dispose() { [Serializable] public class DsVocoderConfig { + // Hard cap on the number of mel bins a vocoder may declare. DiffSinger + // vocoders in the wild use 80, 128 or similar values; values larger than + // this are treated as invalid so that vocoders cannot smuggle through + // onnx models that are actually something else (e.g. a full DiffSinger + // acoustic model masquerading as a vocoder). Kept as a hard-coded + // constant rather than a configurable field on purpose: lowering it + // here is a deliberate code change, not something the voicebank author + // can override. + public const int MaxMelBins = 255; public string name = "vocoder"; public string model = "model.onnx"; public int sample_rate = 44100; diff --git a/OpenUtau/Colors/Brushes.axaml b/OpenUtau/Colors/Brushes.axaml index 1f153db2b..06dd471bc 100644 --- a/OpenUtau/Colors/Brushes.axaml +++ b/OpenUtau/Colors/Brushes.axaml @@ -42,6 +42,10 @@ Color="{DynamicResource ForegroundColorPointerOver}" /> + + diff --git a/OpenUtau/Colors/DarkTheme.axaml b/OpenUtau/Colors/DarkTheme.axaml index 180204fb2..c7a2d5277 100644 --- a/OpenUtau/Colors/DarkTheme.axaml +++ b/OpenUtau/Colors/DarkTheme.axaml @@ -17,6 +17,9 @@ #B0B0B0 #4EA6EA + + #181818 + #30000000 #90CAF9 @@ -31,7 +34,7 @@ #707070 #D0D0D0 #D0D0D0 - #404040 + #BB404040 #433519 @@ -47,4 +50,4 @@ Transparent Transparent #FFFFFF - + \ No newline at end of file diff --git a/OpenUtau/Colors/LightTheme.axaml b/OpenUtau/Colors/LightTheme.axaml index ff064d0d2..a7bf98396 100644 --- a/OpenUtau/Colors/LightTheme.axaml +++ b/OpenUtau/Colors/LightTheme.axaml @@ -17,6 +17,9 @@ #B0B0B0 #4EA6EA + + #dddddd + #10000000 #90CAF9 @@ -31,7 +34,7 @@ #AFA3B5 #AFA3B5 #C0C0C0 - #F0F0F0 + #EEF0F0F0 #FFF4CE diff --git a/OpenUtau/Controls/PianoRoll.axaml b/OpenUtau/Controls/PianoRoll.axaml index caa98e9f8..e70961ea6 100644 --- a/OpenUtau/Controls/PianoRoll.axaml +++ b/OpenUtau/Controls/PianoRoll.axaml @@ -39,6 +39,7 @@