Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EN ARPA+] Fix CCV conditionals with 2 or more consonant clusters #1328

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 13 additions & 19 deletions OpenUtau.Plugin.Builtin/ArpasingPlusPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {

private readonly Dictionary<string, string> vvExceptions =
new Dictionary<string, string>() {
{"e","y"},
{"i","y"},
{"o","w"},
{"u","w"},
{"aw","w"},
{"ow","w"},
{"uw","w"},
Expand Down Expand Up @@ -285,7 +281,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {

// STARTING V
if (syllable.IsStartingV) {
basePhoneme = AliasFormat(v, "startingV", syllable.vowelTone, "");
basePhoneme = AliasFormat(v, "startingV", syllable.vowelTone, "");
}
// [V V] or [V C][C V]/[V]
else if (syllable.IsVV) {
Expand Down Expand Up @@ -328,7 +324,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
/// - CV
if ((HasOto(rcv, syllable.vowelTone) || HasOto(ValidateAlias(rcv), syllable.vowelTone)) || (HasOto(rcv1, syllable.vowelTone) || HasOto(ValidateAlias(rcv1), syllable.vowelTone))) {
basePhoneme = AliasFormat($"{cc[0]} {v}", "dynStart", syllable.vowelTone, "");
/// CV
/// CV
} else if ((HasOto(crv, syllable.vowelTone) || HasOto(ValidateAlias(crv), syllable.vowelTone))) {
basePhoneme = AliasFormat($"{cc[0]} {v}", "dynMid", syllable.vowelTone, "");
TryAddPhoneme(phonemes, syllable.tone, AliasFormat($"{cc[0]}", "cc_start", syllable.vowelTone, ""));
Expand Down Expand Up @@ -467,7 +463,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
cc1 = ValidateAlias(cc1);
}
// CCV
if (syllable.CurrentWordCc.Length == 2) {
if (syllable.CurrentWordCc.Length >= 2) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone) || HasOto(ccv1, syllable.vowelTone) || HasOto(ValidateAlias(ccv1), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = AliasFormat($"{string.Join("", cc.Skip(i + 1))} {v}", "dynMid", syllable.vowelTone, "");
lastC = i;
Expand All @@ -478,12 +474,12 @@ 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
// CV
} else if (syllable.CurrentWordCc.Length == 1 && syllable.PreviousWordCc.Length == 1) {
basePhoneme = AliasFormat($"{cc.Last()} {v}", "dynMid", syllable.vowelTone, "");
// [C1 C2]
if (!HasOto(cc1, syllable.tone)) {
cc1 = $"{cc[i]} {cc[i + 1]}";
cc1 = $"{cc[i]} {cc[i + 1]}";
}
}
// C+V
Expand All @@ -492,7 +488,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
basePhoneme = v;
cc1 = ValidateAlias(cc1);
}

if (i + 1 < lastC) {
if (!HasOto(cc1, syllable.tone)) {
cc1 = ValidateAlias(cc1);
Expand All @@ -514,7 +510,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
cc1 = ValidateAlias(cc1);
}
// CCV
if (syllable.CurrentWordCc.Length == 2) {
if (syllable.CurrentWordCc.Length >= 2) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone) || HasOto(ccv1, syllable.vowelTone) || HasOto(ValidateAlias(ccv1), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = AliasFormat($"{string.Join("", cc.Skip(i + 1))} {v}", "dynMid", syllable.vowelTone, "");
lastC = i;
Expand Down Expand Up @@ -545,7 +541,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
basePhoneme = v;
cc1 = ValidateAlias(cc1);
}

if (HasOto(cc1, syllable.tone) && HasOto(cc1, syllable.tone) && !cc1.Contains($"{string.Join("", cc.Skip(i))}")) {
// like [V C1] [C1 C2] [C2 C3] [C3 ..]
phonemes.Add(cc1);
Expand Down Expand Up @@ -619,7 +615,6 @@ protected override List<string> ProcessEnding(Ending ending) {
firstC = 1;
break;
} else if ((HasOto(vcc2, ending.tone) || HasOto(ValidateAlias(vcc2), ending.tone)) && lastC == 1 && !ccvException.Contains(cc[0])) {

phonemes.Add(vcc2);
firstC = 1;
break;
Expand Down Expand Up @@ -741,7 +736,6 @@ private string AliasFormat(string alias, string type, int tone, string prevV) {
{ "cc_end", new string[] { " -", "-", "" } },
{ "cc_mix", new string[] { " -", " R", "-", "", "_", "- ", "-" } },
{ "cc1_mix", new string[] { "", " -", "-", " R", "_", "- ", "-" } },
{ "cc_b", new string[] { "d", "g", "p" } },
};

// Check if the given type exists in the aliasFormats dictionary
Expand Down Expand Up @@ -810,16 +804,16 @@ private string AliasFormat(string alias, string type, int tone, string prevV) {
// If the alias contains a space, split it into consonant and vowel
if (alias.Contains(" ")) {
var parts = alias.Split(' ');
consonant = parts[0];
vowel = parts[1];
consonant = parts[1];
vowel = parts[0];
} else {
consonant = alias;
}
var dynamicVariations1 = new List<string> {
$"{vowel}{consonant} -", // "VC -"
$"{vowel} {consonant}-", // "V C-"
$"{vowel}{consonant}-", // "VC-"
$"{vowel} {consonant} -", // "V C -"
$"{vowel}{consonant} -", // "VC -"
};
// Check each dynamically generated format
foreach (var variation1 in dynamicVariations1) {
Expand Down Expand Up @@ -1453,7 +1447,7 @@ protected override string ValidateAlias(string alias) {
}
}
}

// glottal
foreach (var v1 in vowels) {
if (!alias.Contains("cl " + v1) || !alias.Contains("q " + v1)) {
Expand Down Expand Up @@ -1553,7 +1547,7 @@ protected override string ValidateAlias(string alias) {
return base.ValidateAlias(alias);
}


protected override double GetTransitionBasicLengthMs(string alias = "") {
//I wish these were automated instead :')
double transitionMultiplier = 1.0; // Default multiplier
Expand Down
Loading