Skip to content

Commit

Permalink
Merge pull request stakira#1243 from Cadlaxa/cadlaxa-local
Browse files Browse the repository at this point in the history
[ARPA+ Phonemizer] Re-adjusted consonant lengths
  • Loading branch information
stakira authored Sep 1, 2024
2 parents b87a905 + 95a9afc commit e2212fb
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions OpenUtau.Plugin.Builtin/ArpasingPlusPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,9 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
}

for (var i = firstC; i < lastC; i++) {
var ccv = $"{string.Join("", cc.Skip(i))} {v}";
var ccv1 = $"{string.Join("", cc.Skip(i))}{v}";
var ccv = $"{string.Join("", cc.Skip(i + 1))} {v}";
var ccv1 = $"{string.Join("", cc.Skip(i + 1))}{v}";
var cccv = $"{string.Join("", cc.Skip(i + 1))} {v}";
var cc1 = $"{string.Join(" ", cc.Skip(i))}";
var lcv = $"{cc.Last()} {v}";
var cv = $"{cc.Last()}{v}";
Expand All @@ -527,16 +528,20 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
if (!HasOto(cc1, syllable.tone)) {
cc1 = ValidateAlias(cc1);
}
// CC V / CCC V on multiple consonants ex [tr ey s] [spr ih ng] (only if the word starts with a CC or CCC...)
if (syllable.CurrentWordCc.Length >= 2) {
// CCCV
if (syllable.CurrentWordCc.Length >= 3) {
if (HasOto(cccv, syllable.vowelTone) || HasOto(ValidateAlias(cccv), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = cccv;
lastC = i;
}
// CCV
} else if (syllable.CurrentWordCc.Length == 2) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = ccv;
lastC = i;
break;
} else if (HasOto(ccv1, syllable.vowelTone) || HasOto(ValidateAlias(ccv1), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = ccv1;
lastC = i;
break;
} else if ((HasOto(lcv, syllable.vowelTone) || HasOto(ValidateAlias(lcv), syllable.vowelTone)) && HasOto(cc1, syllable.vowelTone) && !HasOto(ccv, syllable.vowelTone)) {
basePhoneme = lcv;
} else if ((HasOto(cv, syllable.vowelTone) || HasOto(ValidateAlias(cv), syllable.vowelTone)) && HasOto(cc1, syllable.vowelTone)) {
Expand All @@ -546,6 +551,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
if (HasOto($"{cc[i]} {string.Join("", cc.Skip(i + 1))}", syllable.tone)) {
cc1 = $"{cc[i]} {string.Join("", cc.Skip(i + 1))}";
}
// CV
} else if (syllable.CurrentWordCc.Length == 1 && syllable.PreviousWordCc.Length == 1) {
basePhoneme = lcv;
if ((HasOto(cv, syllable.vowelTone) || HasOto(ValidateAlias(cv), syllable.vowelTone))) {
Expand All @@ -557,7 +563,6 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
}
}
// C+V

if ((HasOto(v, syllable.vowelTone) || HasOto(ValidateAlias(v), syllable.vowelTone)) && (!HasOto(lcv, syllable.vowelTone) && !HasOto(ValidateAlias(lcv), syllable.vowelTone) && (!HasOto(cv, syllable.vowelTone) && !HasOto(ValidateAlias(cv), syllable.vowelTone)))) {
cPV_FallBack = true;
basePhoneme = v;
Expand All @@ -584,16 +589,20 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
// [C1-] [-C2]
phonemes.Add($"{cc[0]} -");
}
// CC V / CCC V on multiple consonants ex [tr ey s] [spr ih ng] (only if the word starts with a CC or CCC...)
if (syllable.CurrentWordCc.Length >= 2) {
// CCCV
if (syllable.CurrentWordCc.Length >= 3) {
if (HasOto(cccv, syllable.vowelTone) || HasOto(ValidateAlias(cccv), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = cccv;
lastC = i;
}
// CCV
} else if (syllable.CurrentWordCc.Length == 2) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = ccv;
lastC = i;
break;
} else if (HasOto(ccv1, syllable.vowelTone) || HasOto(ValidateAlias(ccv1), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = ccv1;
lastC = i;
break;
} else if ((HasOto(lcv, syllable.vowelTone) || HasOto(ValidateAlias(lcv), syllable.vowelTone)) && HasOto(cc1, syllable.vowelTone) && !HasOto(ccv, syllable.vowelTone)) {
basePhoneme = lcv;
} else if ((HasOto(cv, syllable.vowelTone) || HasOto(ValidateAlias(cv), syllable.vowelTone)) && HasOto(cc1, syllable.vowelTone)) {
Expand All @@ -603,6 +612,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
if (HasOto($"{cc[i]} {string.Join("", cc.Skip(i + 1))}", syllable.tone)) {
cc1 = $"{cc[i]} {string.Join("", cc.Skip(i + 1))}";
}
// CV
} else if (syllable.CurrentWordCc.Length == 1 && syllable.PreviousWordCc.Length == 1) {
basePhoneme = lcv;
if ((HasOto(cv, syllable.vowelTone) || HasOto(ValidateAlias(cv), syllable.vowelTone))) {
Expand All @@ -614,7 +624,6 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
}
}
// C+V

if ((HasOto(v, syllable.vowelTone) || HasOto(ValidateAlias(v), syllable.vowelTone)) && (!HasOto(lcv, syllable.vowelTone) && !HasOto(ValidateAlias(lcv), syllable.vowelTone) && (!HasOto(cv, syllable.vowelTone) && !HasOto(ValidateAlias(cv), syllable.vowelTone)))) {
cPV_FallBack = true;
basePhoneme = v;
Expand Down Expand Up @@ -1734,15 +1743,15 @@ protected override double GetTransitionBasicLengthMs(string alias = "") {
var numbers = new List<string> { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

foreach (var c in longConsonants) {
if (alias.Contains(c) && !alias.StartsWith(c) && !alias.Contains("ng -")) {
return base.GetTransitionBasicLengthMs() * 2.5;
if (alias.Contains(c) && !alias.Contains("ng -")) {
return base.GetTransitionBasicLengthMs() * 2.6;
}
}

foreach (var c in normalConsonants) {
foreach (var v in normalConsonants.Except(GlideVCCons)) {
foreach (var b in normalConsonants.Except(NormVCCons)) {
if (alias.Contains(c) && !alias.StartsWith(c) &&
if (alias.Contains(c) &&
!alias.Contains("dx") && !alias.Contains($"{c} -")) {
if ("b,d,g,k,p,t".Split(',').Contains(c)) {
hasCons = true;
Expand Down Expand Up @@ -1774,15 +1783,15 @@ protected override double GetTransitionBasicLengthMs(string alias = "") {
}

foreach (var c in affricates) {
if (alias.Contains(c) && !alias.StartsWith(c)) {
if (alias.Contains(c)) {
return base.GetTransitionBasicLengthMs() * 1.5;
}
}

foreach (var c in connectingGlides) {
foreach (var v in vowels.Except(excludedVowels)) {
if (alias.Contains($"{v} {c}") && !alias.Contains($"{c} -") && !alias.Contains($"{v} -")) {
return base.GetTransitionBasicLengthMs() * 2.5;
return base.GetTransitionBasicLengthMs() * 2.3;
}
}
}
Expand All @@ -1798,24 +1807,24 @@ protected override double GetTransitionBasicLengthMs(string alias = "") {

foreach (var c in semilongConsonants) {
foreach (var v in semilongConsonants.Except(excludedEndings)) {
if (alias.Contains(c) && !alias.StartsWith(c) && !alias.Contains($"{c} -") && !alias.Contains($"- q")) {
if (alias.Contains(c) && !alias.Contains($"{c} -") && !alias.Contains($"- q")) {
return base.GetTransitionBasicLengthMs() * 1.5;
}
}
}

foreach (var c in semiVowels) {
foreach (var v in semilongConsonants.Except(excludedEndings)) {
if (alias.Contains(c) && !alias.StartsWith(c) && !alias.Contains($"{c} -")) {
return base.GetTransitionBasicLengthMs() * 1.5;
if (alias.Contains(c) && !alias.Contains($"{c} -")) {
return base.GetTransitionBasicLengthMs() * 1.6;
}
}
}

if (hasCons) {
return base.GetTransitionBasicLengthMs() * 1.3; // Value for 'cons'
} else if (haslr) {
return base.GetTransitionBasicLengthMs() * 1.7; // Value for 'cons'
return base.GetTransitionBasicLengthMs() * 1.3; // Value for 'cons'
}

// Check if the alias ends with a consonant or vowel
Expand Down

0 comments on commit e2212fb

Please sign in to comment.