Skip to content

Commit cd3bb62

Browse files
authored
Merge pull request stakira#1082 from Cadlaxa/cadlaxa-local
Add support for External Ending notes via `-` or `R` + proper test file
2 parents c648f44 + 18edc0a commit cd3bb62

File tree

10 files changed

+22228
-10827
lines changed

10 files changed

+22228
-10827
lines changed

OpenUtau.Plugin.Builtin/ArpasingPlusPhonemizer.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
4646
protected override string GetDictionaryName() => "cmudict-0_7b.txt";
4747
protected override Dictionary<string, string> GetDictionaryPhonemesReplacement() => dictionaryReplacements;
4848

49+
4950
// For banks with missing vowels
50-
private readonly Dictionary<string, string> missingVphonemes = "ax=ah,aa=ah,ae=ah,iy=ih,uh=uw,ix=ih,ux=uh,oh=ao,eu=uh,oe=ax,uy=uw,yw=uw,yx=iy,wx=uw,ea=eh,ia=iy,oa=ao,ua=uw".Split(',')
51+
private readonly Dictionary<string, string> missingVphonemes = "ax=ah,aa=ah,ae=ah,iy=ih,uh=uw,ix=ih,ux=uh,oh=ao,eu=uh,oe=ax,uy=uw,yw=uw,yx=iy,wx=uw,ea=eh,ia=iy,oa=ao,ua=uw,R=-".Split(',')
5152
.Select(entry => entry.Split('='))
5253
.Where(parts => parts.Length == 2)
5354
.Where(parts => parts[0] != parts[1])
@@ -97,9 +98,13 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
9798
private readonly string[] ccvException = { "ch", "dh", "dx", "fh", "gh", "hh", "jh", "kh", "ph", "ng", "sh", "th", "vh", "wh", "zh" };
9899
private readonly string[] vc_cAcception = { "r", "l" };
99100
private readonly string[] RomajiException = { "a", "e", "i", "o", "u" };
101+
private string[] tails = "-,R,RB".Split(',');
100102

101103
protected override string[] GetSymbols(Note note) {
102104
string[] original = base.GetSymbols(note);
105+
if (tails.Contains(note.lyric)) {
106+
return new string[] { note.lyric };
107+
}
103108
if (original == null) {
104109
return null;
105110
}
@@ -198,9 +203,10 @@ protected override IG2p LoadBaseDictionary() {
198203
g2ps.Add(new ArpabetPlusG2p());
199204
return new G2pFallbacks(g2ps.ToArray());
200205
}
201-
202206
protected override List<string> ProcessSyllable(Syllable syllable) {
203-
string prevV = syllable.prevV;
207+
syllable.prevV = tails.Contains(syllable.prevV) ? "" : syllable.prevV;
208+
var prevV = syllable.prevV == "" ? "" : $"{syllable.prevV}";
209+
//string prevV = syllable.prevV;
204210
string[] cc = syllable.cc;
205211
string v = syllable.v;
206212
string basePhoneme;
@@ -354,7 +360,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
354360
for (var i = firstC; i < cc.Length - 1; i++) {
355361
var ccv = $"{string.Join("", cc)} {v}";
356362
var ccv1 = string.Join("", cc.Skip(i)) + " " + v;
357-
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[0])) {
363+
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[i] + cc[i + 1])) {
358364
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone)) {
359365
basePhoneme = ccv;
360366
lastC = i;
@@ -375,7 +381,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
375381
var vc = $"{prevV} {cc[0]}";
376382
// CCV will trigger VCC
377383
bool CCV = false;
378-
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[0])) {
384+
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[1])) {
379385
if (HasOto($"{string.Join("", cc)} {v}", syllable.vowelTone) || HasOto(ValidateAlias($"{string.Join("", cc)} {v}"), syllable.vowelTone)) {
380386
CCV = true;
381387
}
@@ -516,6 +522,9 @@ protected override List<string> ProcessEnding(Ending ending) {
516522
var phonemes = new List<string>();
517523
var lastC = cc.Length - 1;
518524
var firstC = 0;
525+
if (tails.Contains(ending.prevV)) {
526+
return new List<string>();
527+
}
519528
if (ending.IsEndingV) {
520529
var vR = $"{v} -";
521530
var vR1 = $"{v} R";

OpenUtau.Test/Files/en_arpa-plus/A#3/oto.ini

Lines changed: 5548 additions & 0 deletions
Large diffs are not rendered by default.

OpenUtau.Test/Files/en_arpa-plus/C3/oto.ini

Lines changed: 5548 additions & 0 deletions
Large diffs are not rendered by default.

OpenUtau.Test/Files/en_arpa-plus/F3 - Main/oto.ini

Lines changed: 5532 additions & 0 deletions
Large diffs are not rendered by default.

OpenUtau.Test/Files/en_arpa-plus/High/oto.ini

Lines changed: 0 additions & 2702 deletions
This file was deleted.

OpenUtau.Test/Files/en_arpa-plus/Low/oto.ini

Lines changed: 0 additions & 2702 deletions
This file was deleted.

OpenUtau.Test/Files/en_arpa-plus/Main/oto.ini

Lines changed: 0 additions & 2702 deletions
This file was deleted.

OpenUtau.Test/Files/en_arpa-plus/Whisper/oto.ini

Lines changed: 5548 additions & 2702 deletions
Large diffs are not rendered by default.

OpenUtau.Test/Files/en_arpa-plus/character.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ subbanks:
99
- F6-B7
1010
- color: ''
1111
prefix: ''
12-
suffix: _1
12+
suffix: _A#3
1313
tone_ranges:
1414
- D#5-E6
1515
- color: ''
1616
prefix: ''
17-
suffix: _3
17+
suffix: _C3
1818
tone_ranges:
1919
- B2-C#4
2020
- color: Whisper

OpenUtau.Test/Plugins/EnArpaPlusTest.cs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ protected override Phonemizer CreatePhonemizer() {
1313

1414
[Theory]
1515
[InlineData("en_arpa-plus",
16-
new string[] { "good", "morning" },
17-
new string[] { "C4", "C4" },
16+
new string[] { "good", "morning", },
17+
new string[] { "A#3", "A#3" },
1818
new string[] { "", "" },
19-
new string[] { "- g_3", "g uh_3", "uh d_3", "d m_3", "m ao_3", "ao r_3", "r n_3", "n ih_3", "ih ng_3", "ng -_3" })]
19+
new string[] { "- g_C3", "g uh_C3", "uh d_C3", "d m_C3", "m ao_C3", "ao r_C3", "r n_C3", "n ih_C3", "ih ng_C3", "ng -_C3" })]
2020
[InlineData("en_arpa-plus",
2121
new string[] { "good", "morning" },
22-
new string[] { "A3", "F4" },
22+
new string[] { "C3", "C3" },
2323
new string[] { "", "" },
24-
new string[] { "- g_3", "g uh_3", "uh d_3", "d m_3", "m ao", "ao r", "r n", "n ih", "ih ng", "ng -" })]
24+
new string[] { "- g_C3", "g uh_C3", "uh d_C3", "d m_C3", "m ao_C3", "ao r_C3", "r n_C3", "n ih_C3", "ih ng_C3", "ng -_C3" })]
2525
public void PhonemizeTest(string singerName, string[] lyrics, string[] tones, string[] colors, string[] aliases) {
2626
RunPhonemizeTest(singerName, lyrics, RepeatString(lyrics.Length, ""), tones, colors, aliases);
2727
}
@@ -32,7 +32,7 @@ public void ColorTest() {
3232
new NoteParams {
3333
lyric = "hi",
3434
hint = "",
35-
tone = "C4",
35+
tone = "A#3",
3636
phonemes = new PhonemeParams[] {
3737
new PhonemeParams {
3838
alt = 0,
@@ -51,17 +51,41 @@ public void ColorTest() {
5151
}
5252
}
5353
}
54-
}, new string[] { "- hh_3", "hh ay_W", "ay -_3" });
54+
}, new string[] { "- hh_C3", "hh ay_W", "ay -_C3" });
55+
}
56+
public void SyllableTest(string lyric, string hint, string[] aliases) {
57+
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "") } }, aliases);
5558
}
59+
[Theory]
60+
[InlineData("read", "", new string[] { "- r_C3", "r eh_C3", "eh d_C3", "d -_C3" })]
61+
[InlineData("read", "r iy d", new string[] { "- r_C3", "r iy_C3", "iy d_C3", "d -_C3" })]
5662

63+
[InlineData("asdfjkl", "r iy d", new string[] { "- r_C3", "r iy_C3", "iy d_C3", "d -_C3" })]
64+
[InlineData("", "r iy d", new string[] { "- r_C3", "r iy_C3", "iy d_C3", "d -_C3" })]
65+
66+
public void SyllableExternalEndingTest(string lyric, string hint, string[] aliases) {
67+
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "") } }, aliases);
68+
}
69+
[Theory]
70+
[InlineData("more", "m aor", new string[] { "- m_C3", "m ao_C3", "ao r_C3", "r -_C3" })]
71+
[InlineData("'a", "q ax hh", new string[] { "- q_C3", "q ax_C3", "ax hh_C3", "hh -_C3" })]
72+
73+
public void SyllableCCVTest(string lyric, string hint, string[] aliases) {
74+
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "") } }, aliases);
75+
}
76+
[Theory]
77+
[InlineData("trusting", "", new string[] { "- tr_C3", "tr ah_C3", "ah st_C3", "st ih_C3", "ih ng_C3", "ng -_C3" })]
78+
[InlineData("drive", "", new string[] { "- dr_C3", "dr ay_C3", "ay v_C3", "v -_C3" })]
79+
80+
public void SyllableFallbackTest(string lyric, string hint, string[] aliases) {
81+
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "") } }, aliases);
82+
}
5783
[Theory]
58-
[InlineData("read", "", new string[] { "- r_3", "r eh_3", "eh d_3", "d -_3" })]
59-
[InlineData("read", "r iy d", new string[] { "- r_3", "r iy_3", "iy d_3", "d -_3" })]
84+
[InlineData("kroidroi", "", new string[] { "- kr_C3", "kr oy_C3", "iy dr_C3", "dr oy_C3", "oy -_C3" })]
85+
[InlineData("whhat", "", new string[] { "- hh_C3", "hh uw_C3", "w ah_C3", "ah t_C3", "t -_C3" })]
6086

61-
[InlineData("asdfjkl", "r iy d", new string[] { "- r_3", "r iy_3", "iy d_3", "d -_3" })]
62-
[InlineData("", "r iy d", new string[] { "- r_3", "r iy_3", "iy d_3", "d -_3" })]
6387
public void HintTest(string lyric, string hint, string[] aliases) {
64-
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C4", phonemes = SamePhonemeParams(4, 0, 0, "")} }, aliases);
88+
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "")} }, aliases);
6589
}
6690
}
6791
}

0 commit comments

Comments
 (0)