Skip to content

Commit

Permalink
fix audio timing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
oxygen-dioxide committed Aug 17, 2023
1 parent b14d0cd commit e7912b3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ float[] InvokeDiffsinger(RenderPhrase phrase,int speedup) {
var vocoder = singer.getVocoder();
var frameMs = vocoder.frameMs();
var frameSec = frameMs / 1000;
int headFrames = (int)(headMs / frameMs);
int tailFrames = (int)(tailMs / frameMs);
int headFrames = (int)Math.Round(headMs / frameMs);
int tailFrames = (int)Math.Round(tailMs / frameMs);
var result = Layout(phrase);
//acoustic
//mel = session.run(['mel'], {'tokens': tokens, 'durations': durations, 'f0': f0, 'speedup': speedup})[0]
Expand All @@ -128,11 +128,11 @@ float[] InvokeDiffsinger(RenderPhrase phrase,int speedup) {
.Select(x => (long)(singer.phonemes.IndexOf(x)))
.ToList();
var durations = phrase.phones
.Select(p => (int)(p.endMs / frameMs) - (int)(p.positionMs / frameMs))//prevent cumulative error
.Select(p => (int)Math.Round(p.endMs / frameMs) - (int)Math.Round(p.positionMs / frameMs))//prevent cumulative error
.Prepend(headFrames)
.Append(tailFrames)
.ToList();
var totalFrames = (int)(durations.Sum());
int totalFrames = durations.Sum();
float[] f0 = DiffSingerUtils.SampleCurve(phrase, phrase.pitches, 0, frameMs, totalFrames, headFrames, tailFrames,
x => MusicMath.ToneToFreq(x * 0.01))
.Select(f => (float)f).ToArray();
Expand Down

0 comments on commit e7912b3

Please sign in to comment.