Skip to content

Commit 680eb14

Browse files
committed
Semi-oto/vel implementation for FC + some consonant fixes
1 parent 651f0cc commit 680eb14

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

KoreanCVVCPlusPhonemizer/KoreanCVVCPlusPhonemizer.cs

+20-3
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,11 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
494494

495495
if ((TCLfinal == "M") && (TNLconsonant == "r")) { TNLconsonant = "n"; }
496496

497-
if ((TCLfinal == "T") && (TNLconsonant == "s")) { TCLfinal = ""; TNLconsonant = "ss"; }
497+
if ((TCLfinal == "T") && (TNLconsonant == "s" || TNLconsonant == "ss")) { TCLfinal = ""; TNLconsonant = "ss"; }
498498

499499
if ((TCLfinal == "NG") && (TNLconsonant == "r")) { TNLconsonant = "n"; }
500500

501+
if ((TCLfinal == "L") && (TNLconsonant == "d")) { TNLconsonant = "dd"; }
501502

502503
// Hanja batchim base ㄱ(g)ㄷ(d)ㅂ(b) + ㄹ(l) = ㅇ(ng)ㄴ(n)ㅁ(m) + ㄴ(n)(2)
503504
if ((TCLfinal == "K") && (NLconsonant == 5)) { TCLfinal = "NG"; TCLplainfinal = "NG"; } else if ((TCLfinal == "T") && (NLconsonant == 5)) { TCLfinal = "N"; TCLplainfinal = "N"; } else if ((TCLfinal == "P") && (NLconsonant == 5)) { TCLfinal = "M"; TCLplainfinal = "M"; }
@@ -737,12 +738,20 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
737738
} else {
738739
ccLength = MsToTick(oto0.Preutter);
739740
}
740-
fcLength = fcLength + ccLength;
741741
}
742742

743743
var nextAttr = nextNeighbour.Value.phonemeAttributes?.FirstOrDefault(attr => attr.index == 0) ?? default;
744+
if ((TCLfinal == "K" || TCLfinal == "T" || TCLfinal == "P") && singer.TryGetMappedOto(CC, nextNeighbour.Value.tone + attr0.toneShift, attr0.voiceColor, out var oto4)) {
745+
if (oto4.Overlap < 0) {
746+
fcLength = MsToTick(oto4.Preutter - oto4.Overlap);
747+
} else {
748+
fcLength = MsToTick(oto4.Preutter);
749+
}
750+
}
751+
744752
// Minimum is 5 tick, maximum is half of note
745753
ccLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(5, ccLength * (nextAttr.consonantStretchRatio ?? 1))));
754+
fcLength = Convert.ToInt32(Math.Min(totalDuration / 1.5, Math.Max(5, fcLength + (ccLength * (nextAttr.consonantStretchRatio ?? 1)))));
746755

747756
if (singer.TryGetMappedOto(CV, note.tone + attr0.toneShift, attr0.voiceColor, out var oto1) && singer.TryGetMappedOto(FC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto2) && singer.TryGetMappedOto(CC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto3)) {
748757
CV = oto1.Alias;
@@ -777,11 +786,19 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
777786
} else {
778787
ccLength = MsToTick(oto0.Preutter);
779788
}
780-
fcLength = fcLength + ccLength;
781789
}
782790

783791
var nextAttr = nextNeighbour.Value.phonemeAttributes?.FirstOrDefault(attr => attr.index == 0) ?? default;
792+
if ((TCLfinal == "K" || TCLfinal == "T" || TCLfinal == "P") && singer.TryGetMappedOto(CC, nextNeighbour.Value.tone + attr0.toneShift, attr0.voiceColor, out var oto4)) {
793+
if (oto4.Overlap < 0) {
794+
fcLength = MsToTick(oto4.Preutter - oto4.Overlap);
795+
} else {
796+
fcLength = MsToTick(oto4.Preutter);
797+
}
798+
}
799+
784800
// Minimum is 5 tick, maximum is half of note
801+
fcLength = Convert.ToInt32(Math.Min(totalDuration / 1.5, Math.Max(5, fcLength + (ccLength * (nextAttr.consonantStretchRatio ?? 1)))));
785802
ccLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(5, ccLength * (nextAttr.consonantStretchRatio ?? 1))));
786803

787804
if (singer.TryGetMappedOto(CV, note.tone + attr0.toneShift, attr0.voiceColor, out var oto1) && singer.TryGetMappedOto(FC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto2) && singer.TryGetMappedOto(CC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto3)) {

0 commit comments

Comments
 (0)