Skip to content

Commit 63b7de4

Browse files
authored
Add files via upload
1 parent 92e17ff commit 63b7de4

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

ARPAsingPlusPhonemizer/ArpasingPlusPhonemizer.cs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
2323
"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",
2424
"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",
2525
"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",
26-
"eu", "oe", "yw"
26+
"eu", "oe", "yw", "yx", "wx"
2727
};
2828
private readonly string[] consonants = "b,ch,d,dh,dr,dx,f,g,hh,jh,k,l,m,n,ng,p,q,r,s,sh,t,th,tr,v,w,y,z,zh".Split(',');
2929
private readonly string[] affricates = "ch,jh,j".Split(',');
@@ -52,7 +52,7 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
5252
private bool isMissingVPhonemes = false;
5353

5454
// For banks with missing custom consonants
55-
private readonly Dictionary<string, string> missingCphonemes = "nx=n,cl=q,wh=w,dx=d,zh=sh,z=s".Split(',')
55+
private readonly Dictionary<string, string> missingCphonemes = "nx=n,cl=q,vf=q,wh=w,dx=d,zh=sh,z=s".Split(',')
5656
.Select(entry => entry.Split('='))
5757
.Where(parts => parts.Length == 2)
5858
.Where(parts => parts[0] != parts[1])
@@ -68,7 +68,7 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
6868
private bool isTimitPhonemes = false;
6969

7070
// other ARPAbet
71-
private readonly Dictionary<string, string> otherArpaphonemes = "oh=ao,eu=uh,oe=ax,uy=uw,yw=uw".Split(',')
71+
private readonly Dictionary<string, string> otherArpaphonemes = "oh=ao,eu=uh,oe=ax,uy=uw,yw=uw,yx=iy,wx=uw".Split(',')
7272
.Select(entry => entry.Split('='))
7373
.Where(parts => parts.Length == 2)
7474
.Where(parts => parts[0] != parts[1])
@@ -274,8 +274,12 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
274274
basePhoneme = vv;
275275
} else if (hasOtoContainsVvWithoutDiphthongs) {
276276
basePhoneme = vv;
277-
} else {
277+
} else if (HasOto(v, syllable.vowelTone) || HasOto(ValidateAlias(v), syllable.vowelTone)) {
278278
basePhoneme = v;
279+
} else {
280+
// MAKE THEM A GLOTTAL STOP INSTEAD
281+
basePhoneme = $"q {v}";
282+
phonemes.Add($"{prevV} q");
279283
}
280284
}
281285

@@ -492,19 +496,33 @@ protected override List<string> ProcessEnding(Ending ending) {
492496
var lastC = cc.Length - 1;
493497
var firstC = 0;
494498
if (ending.IsEndingV) {
495-
TryAddPhoneme(phonemes, ending.tone, $"{v} -", $"{v} R", $"{v}-");
499+
var vR = $"{v} -";
500+
var vR1 = $"{v} R";
501+
var vR2 = $"{v}-";
502+
if (HasOto(vR, ending.tone) || HasOto(ValidateAlias(vR), ending.tone)) {
503+
phonemes.Add(vR);
504+
} else if (!HasOto(vR, ending.tone) && !HasOto(ValidateAlias(vR), ending.tone) && (HasOto(vR1, ending.tone) || HasOto(ValidateAlias(vR1), ending.tone))) {
505+
phonemes.Add(vR1);
506+
} else if (!HasOto(vR1, ending.tone) && !HasOto(ValidateAlias(vR1), ending.tone) && (HasOto(vR2, ending.tone) || HasOto(ValidateAlias(vR2), ending.tone))) {
507+
phonemes.Add(vR2);
508+
} else {
509+
phonemes.Add(vR);
510+
}
496511
} else if (ending.IsEndingVCWithOneConsonant) {
497512
var vc = $"{v} {cc[0]}";
498513
var vcr = $"{v} {cc[0]}-";
499514
var vcr2 = $"{v}{cc[0]} -";
515+
var vcr3 = $"{v}{cc[0]}-";
500516
if (HasOto(vcr, ending.tone) || HasOto(ValidateAlias(vcr), ending.tone)) {
501517
phonemes.Add(vcr);
502518
} else if (!HasOto(vcr, ending.tone) && !HasOto(ValidateAlias(vcr), ending.tone) && (HasOto(vcr2, ending.tone) || HasOto(ValidateAlias(vcr2), ending.tone))) {
503519
phonemes.Add(vcr2);
520+
} else if (!HasOto(vcr2, ending.tone) && !HasOto(ValidateAlias(vcr2), ending.tone) && (HasOto(vcr3, ending.tone) || HasOto(ValidateAlias(vcr3), ending.tone))) {
521+
phonemes.Add(vcr3);
504522
} else {
505523
phonemes.Add(vc);
506524
if (vc.Contains(cc[0])) {
507-
TryAddPhoneme(phonemes, ending.tone, $"{cc[0]} -", cc[0]);
525+
phonemes.Add($"{cc[0]} -");
508526
}
509527
}
510528
} else {
@@ -1181,7 +1199,7 @@ protected override string ValidateAlias(string alias) {
11811199
return alias.Replace("uw tr", "uw t");
11821200
}
11831201
if (alias == "uw zh") {
1184-
return alias.Replace("uw zh", "uw z");
1202+
return alias.Replace("uw zh", "uw sh");
11851203
}
11861204
}
11871205

@@ -1781,8 +1799,6 @@ protected override string ValidateAlias(string alias) {
17811799
alias = alias.Replace(str, "er" + " " + s);
17821800
} else if (c1 == "n") {
17831801
alias = alias.Replace(str, "m" + " " + s);
1784-
} else if (c1 == "l") {
1785-
alias = alias.Replace(str, "r" + " " + s);
17861802
} else if (c1 == "ng" || c1 == "m") {
17871803
alias = alias.Replace(str, "n" + " " + s);
17881804
} else if (c1 == "sh" || c1 == "zh" || c1 == "th" || c1 == "z" || c1 == "f") {

0 commit comments

Comments
 (0)