Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions OpenUtau.Core/DiffSinger/DiffSingerMandarinPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}
},
};
Expand Down
8 changes: 5 additions & 3 deletions OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> supportedExp = new HashSet<string>(){
Format.Ustx.DYN,
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}

Expand Down