From a0a7c18a086232c6ceb008f2107eb3944b36f965 Mon Sep 17 00:00:00 2001 From: oxygen-dioxide <54425948+oxygen-dioxide@users.noreply.github.com> Date: Mon, 16 Jan 2023 22:42:51 +0800 Subject: [PATCH] tailMs and consonant duration limit --- OpenUtau.Core/DiffSinger/DiffSingerMandarinPhonemizer.cs | 8 ++++++-- OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/OpenUtau.Core/DiffSinger/DiffSingerMandarinPhonemizer.cs b/OpenUtau.Core/DiffSinger/DiffSingerMandarinPhonemizer.cs index 2bc1c82b1..05b2ffe5a 100644 --- a/OpenUtau.Core/DiffSinger/DiffSingerMandarinPhonemizer.cs +++ b/OpenUtau.Core/DiffSinger/DiffSingerMandarinPhonemizer.cs @@ -71,10 +71,14 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN //使用vogen的辅音时间 Result VogenResult = base.Process(notes, prev, next, prevNeighbour, nextNeighbour, prevs); //辅音长度至少为1帧 + int consonantPos = Math.Min(VogenResult.phonemes[0].position, -frameTick); + //辅音长度不能超过上一音符时长的2/3 + if (prevNeighbour != null) { + consonantPos = Math.Max(consonantPos, -prevNeighbour.Value.duration * 2 / 3); + } return new Result { phonemes = new Phoneme[] { - new Phoneme {phoneme = phones.Item1, - position = Math.Min(VogenResult.phonemes[0].position,-frameTick)}, + new Phoneme {phoneme = phones.Item1, position = consonantPos}, new Phoneme {phoneme = phones.Item2, position = 0} }, }; diff --git a/OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs b/OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs index ac47ff659..e1ea1b0c9 100644 --- a/OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs +++ b/OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs @@ -16,7 +16,7 @@ namespace OpenUtau.Core.DiffSinger { public class DiffSingerRenderer : IRenderer { const float headMs = 0; - const float tailMs = 0; + const float tailMs = 500; static readonly HashSet supportedExp = new HashSet(){ Format.Ustx.DYN, @@ -109,10 +109,12 @@ float[] InvokeDiffsinger(RenderPhrase phrase,int speedup) { //speedup:加速倍数 var tokens = phrase.phones .Select(p => p.phoneme) + .Append("SP") .Select(x => (long)(singer.phonemes.IndexOf(x))) .ToList(); var durations = phrase.phones .Select(p => (long)(p.endMs / frameMs) - (long)(p.positionMs / frameMs))//防止累计误差 + .Append(tailFrames) .ToList(); var totalFrames = (int)(durations.Sum()); var f0 = SampleCurve(phrase, phrase.pitches, 0, totalFrames, headFrames, tailFrames, x => MusicMath.ToneToFreq(x * 0.01)); @@ -167,8 +169,8 @@ double[] SampleCurve(RenderPhrase phrase, float[] curve, double defaultValue, in } } //填充头尾 - Array.Fill(result, defaultValue, 0, headFrames); - Array.Fill(result, defaultValue, length - tailFrames, tailFrames); + Array.Fill(result, convert(curve[0]), 0, headFrames); + Array.Fill(result, convert(curve.Last()), length - tailFrames, tailFrames); return result; }