Skip to content

Commit

Permalink
changes to note extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadlaxa authored Feb 1, 2024
1 parent 41d6588 commit eb5db6a
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions ARPAsingPlusPhonemizer/ArpasingPlusPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using NumSharp.Utilities;
using OpenUtau.Api;
using OpenUtau.Core.G2p;
using Serilog;
Expand All @@ -23,7 +22,7 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
"naan", "an", "axn", "aen", "ahn", "aon", "on", "awn", "aun", "ayn", "ain", "ehn", "en", "eyn", "ein", "ihn", "iyn", "in", "own", "oun", "oyn", "oin", "uhn", "uwn", "un",
"aang", "ang", "axng", "aeng", "ahng", "aong", "ong", "awng", "aung", "ayng", "aing", "ehng", "eng", "eyng", "eing", "ihng", "iyng", "ing", "owng", "oung", "oyng", "oing", "uhng", "uwng", "ung",
"aam", "am", "axm", "aem", "ahm", "aom", "om", "awm", "aum", "aym", "aim", "ehm", "em", "eym", "eim", "ihm", "iym", "im", "owm", "oum", "oym", "oim", "uhm", "uwm", "um", "oh",
"eu", "oe", "yw", "yx", "wx"
"eu", "oe", "yw", "yx", "wx", "ox", "ex"
};
private readonly string[] consonants = "b,ch,d,dh,dx,f,g,hh,jh,k,l,m,n,ng,p,q,r,s,sh,t,th,v,w,y,z,zh".Split(',');
private readonly string[] affricates = "ch,jh,j".Split(',');
Expand Down Expand Up @@ -93,9 +92,9 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
{"el","l"},
};
private readonly string[] ccvException = { "ch", "dh", "dx", "fh", "gh", "hh", "jh", "kh", "ph", "ng", "sh", "th", "vh", "wh", "zh" };
private readonly string[] vc_cException = { "r", "l" };
private readonly string[] vc_cAcception = { "r", "l" };
private readonly string[] RomajiException = { "a", "e", "i", "o", "u" };

protected override string[] GetSymbols(Note note) {
string[] original = base.GetSymbols(note);
if (original == null) {
Expand Down Expand Up @@ -252,7 +251,8 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
basePhoneme = crv;
}
} else {
{ if (HasOto($"{prevV} {v}", syllable.vowelTone) || HasOto(ValidateAlias($"{prevV} {v}"), syllable.vowelTone)) {
{
if (HasOto($"{prevV} {v}", syllable.vowelTone) || HasOto(ValidateAlias($"{prevV} {v}"), syllable.vowelTone)) {
basePhoneme = $"{prevV} {v}";
} else if (HasOto(v, syllable.vowelTone) || HasOto(ValidateAlias(v), syllable.vowelTone)) {
basePhoneme = v;
Expand All @@ -263,11 +263,14 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
}
}
}
} else if (HasOto($"{v}", syllable.vowelTone) || vowels.Contains(v) && !CanMakeAliasExtension(syllable)) {
basePhoneme = v;
} else {
// PREVIOUS ALIAS WILL EXTEND
// PREVIOUS ALIAS WILL EXTEND as V
basePhoneme = null;
}
// [C V] or [CV]

// [- CV/C V] or [- C][CV/C V]
} else if (syllable.IsStartingCVWithOneConsonant) {
var rcv = $"- {cc[0]} {v}";
var rcv1 = $"- {cc[0]}{v}";
Expand All @@ -293,7 +296,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
TryAddPhoneme(phonemes, syllable.tone, $"- {cc[0]}", ValidateAlias($"- {cc[0]}"));
break;
}
// [CC V] or [C C] + [C V]
// [CCV/CC V] or [C C] + [CV/C V]
} else if (syllable.IsStartingCVWithMoreThanOneConsonant) {
// TRY [- CCV]/[- CC V] or [- CC][CCV]/[CC V] or [- C][C C][C V]/[CV]
var rccv = $"- {string.Join("", cc)} {v}";
Expand All @@ -319,9 +322,8 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
if (!ccvException.Contains(cc[0])) {
if (TryAddPhoneme(phonemes, syllable.tone, $"- {string.Join("", cc.Take(i))}", ValidateAlias($"- {string.Join("", cc.Take(i))}"))) {
firstC = i - 1;
break;
}
}
} break;
}
// [- C]
if (phonemes.Count == 0) {
Expand Down Expand Up @@ -375,9 +377,9 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
firstC = 1;
break;
}
} else if (vc_cException.Contains(cc[0]) && HasOto(vc_c, syllable.tone) || HasOto(ValidateAlias(vc_c), syllable.tone)) {
phonemes.Add(vc_c);
firstC = 1;
//} else if (vc_cAcception.Contains(cc[0]) && syllable.PreviousWordCc.Length >= 2 && HasOto(vc_c, syllable.tone) && !HasOto($"{prevV}{string.Join(" ", cc.Take(1))}", syllable.tone) || HasOto(ValidateAlias(vc_c), syllable.tone)) {
// phonemes.Add(vc_c);
// firstC = 1;
break;
} else if (HasOto(vc, syllable.tone) || HasOto(ValidateAlias(vc), syllable.tone)) {
phonemes.Add(vc);
Expand Down Expand Up @@ -412,8 +414,8 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
cc1 = ValidateAlias(cc1);
}
// CC V on multiple consonants ex [s tr ao] (only if the word starts with a CC)
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[0])) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone)) {
if (syllable.CurrentWordCc.Length >= 2) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = ccv;
lastC = i;
break;
Expand Down Expand Up @@ -452,8 +454,8 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
cc1 = ValidateAlias(cc1);
}
// CC V on multiple consonants ex [s tr ao] (only if the word starts with a CC)
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[0])) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone)) {
if (syllable.CurrentWordCc.Length >= 2) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone) && !ccvException.Contains(cc[0])) {
basePhoneme = ccv;
lastC = i;
break;
Expand Down Expand Up @@ -1874,7 +1876,7 @@ 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")) {
return base.GetTransitionBasicLengthMs() * 2.0;
return base.GetTransitionBasicLengthMs() * 1.5;
}
}
}
Expand Down

0 comments on commit eb5db6a

Please sign in to comment.