Skip to content

Commit 1a33688

Browse files
Merge pull request #51 from oxygen-dioxide/diffsinger
Diffsinger
2 parents 289618b + 29a5cfd commit 1a33688

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Diff for: OpenUtau.Core/DiffSinger/DiffSingerPhonemizer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ List<phonemesPerNote> ProcessWord(Note[] notes){
120120
//distribute phonemes to notes
121121
var noteIndex = 0;
122122
for (int i = 0; i < symbols.Length; i++) {
123-
if (isVowel[i] && noteIndex <= nonExtensionNotes.Length) {
123+
if (isVowel[i] && noteIndex < nonExtensionNotes.Length) {
124124
var note = nonExtensionNotes[noteIndex];
125125
wordPhonemes.Add(new phonemesPerNote(note.position, note.tone, new List<string>()));
126126
noteIndex++;

Diff for: OpenUtau.Core/DiffSinger/DiffSingerPitch.cs

+15-5
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,23 @@ public RenderPitchResult Process(RenderPhrase phrase){
147147
new DenseTensor<long>(new long[] { speedup }, new int[] { 1 },false)));
148148
var pitchOutputs = pitchModel.Run(pitchInputs);
149149
var pitch_out = pitchOutputs.First().AsTensor<float>().ToArray();
150-
151-
return new RenderPitchResult{
152-
ticks = Enumerable.Range(0,n_frames)
150+
var pitchEnd = phrase.timeAxis.MsPosToTickPos(startMs + (n_frames - 1) * frameMs) - phrase.position;
151+
if(pitchEnd<=phrase.duration){
152+
return new RenderPitchResult{
153+
ticks = Enumerable.Range(0,n_frames)
153154
.Select(i=>(float)phrase.timeAxis.MsPosToTickPos(startMs + i*frameMs) - phrase.position)
155+
.Append((float)phrase.duration + 1)
154156
.ToArray(),
155-
tones = pitch_out
156-
};
157+
tones = pitch_out.Append(pitch_out[^1]).ToArray()
158+
};
159+
}else{
160+
return new RenderPitchResult{
161+
ticks = Enumerable.Range(0,n_frames)
162+
.Select(i=>(float)phrase.timeAxis.MsPosToTickPos(startMs + i*frameMs) - phrase.position)
163+
.ToArray(),
164+
tones = pitch_out
165+
};
166+
}
157167
}
158168
}
159169
}

0 commit comments

Comments
 (0)