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

Add support for External Ending notes via - or R + proper test file #1082

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 14 additions & 5 deletions OpenUtau.Plugin.Builtin/ArpasingPlusPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
protected override string GetDictionaryName() => "cmudict-0_7b.txt";
protected override Dictionary<string, string> GetDictionaryPhonemesReplacement() => dictionaryReplacements;


// For banks with missing vowels
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(',')
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(',')
.Select(entry => entry.Split('='))
.Where(parts => parts.Length == 2)
.Where(parts => parts[0] != parts[1])
Expand Down Expand Up @@ -97,9 +98,13 @@ public class ArpasingPlusPhonemizer : SyllableBasedPhonemizer {
private readonly string[] ccvException = { "ch", "dh", "dx", "fh", "gh", "hh", "jh", "kh", "ph", "ng", "sh", "th", "vh", "wh", "zh" };
private readonly string[] vc_cAcception = { "r", "l" };
private readonly string[] RomajiException = { "a", "e", "i", "o", "u" };
private string[] tails = "-,R,RB".Split(',');

protected override string[] GetSymbols(Note note) {
string[] original = base.GetSymbols(note);
if (tails.Contains(note.lyric)) {
return new string[] { note.lyric };
}
if (original == null) {
return null;
}
Expand Down Expand Up @@ -198,9 +203,10 @@ protected override IG2p LoadBaseDictionary() {
g2ps.Add(new ArpabetPlusG2p());
return new G2pFallbacks(g2ps.ToArray());
}

protected override List<string> ProcessSyllable(Syllable syllable) {
string prevV = syllable.prevV;
syllable.prevV = tails.Contains(syllable.prevV) ? "" : syllable.prevV;
var prevV = syllable.prevV == "" ? "" : $"{syllable.prevV}";
//string prevV = syllable.prevV;
string[] cc = syllable.cc;
string v = syllable.v;
string basePhoneme;
Expand Down Expand Up @@ -354,7 +360,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
for (var i = firstC; i < cc.Length - 1; i++) {
var ccv = $"{string.Join("", cc)} {v}";
var ccv1 = string.Join("", cc.Skip(i)) + " " + v;
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[0])) {
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[i] + cc[i + 1])) {
if (HasOto(ccv, syllable.vowelTone) || HasOto(ValidateAlias(ccv), syllable.vowelTone)) {
basePhoneme = ccv;
lastC = i;
Expand All @@ -375,7 +381,7 @@ protected override List<string> ProcessSyllable(Syllable syllable) {
var vc = $"{prevV} {cc[0]}";
// CCV will trigger VCC
bool CCV = false;
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[0])) {
if (syllable.CurrentWordCc.Length >= 2 && !ccvException.Contains(cc[1])) {
if (HasOto($"{string.Join("", cc)} {v}", syllable.vowelTone) || HasOto(ValidateAlias($"{string.Join("", cc)} {v}"), syllable.vowelTone)) {
CCV = true;
}
Expand Down Expand Up @@ -516,6 +522,9 @@ protected override List<string> ProcessEnding(Ending ending) {
var phonemes = new List<string>();
var lastC = cc.Length - 1;
var firstC = 0;
if (tails.Contains(ending.prevV)) {
return new List<string>();
}
if (ending.IsEndingV) {
var vR = $"{v} -";
var vR1 = $"{v} R";
Expand Down
5,548 changes: 5,548 additions & 0 deletions OpenUtau.Test/Files/en_arpa-plus/A#3/oto.ini

Large diffs are not rendered by default.

5,548 changes: 5,548 additions & 0 deletions OpenUtau.Test/Files/en_arpa-plus/C3/oto.ini

Large diffs are not rendered by default.

5,532 changes: 5,532 additions & 0 deletions OpenUtau.Test/Files/en_arpa-plus/F3 - Main/oto.ini

Large diffs are not rendered by default.

2,702 changes: 0 additions & 2,702 deletions OpenUtau.Test/Files/en_arpa-plus/High/oto.ini

This file was deleted.

2,702 changes: 0 additions & 2,702 deletions OpenUtau.Test/Files/en_arpa-plus/Low/oto.ini

This file was deleted.

2,702 changes: 0 additions & 2,702 deletions OpenUtau.Test/Files/en_arpa-plus/Main/oto.ini

This file was deleted.

8,250 changes: 5,548 additions & 2,702 deletions OpenUtau.Test/Files/en_arpa-plus/Whisper/oto.ini

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions OpenUtau.Test/Files/en_arpa-plus/character.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ subbanks:
- F6-B7
- color: ''
prefix: ''
suffix: _1
suffix: _A#3
tone_ranges:
- D#5-E6
- color: ''
prefix: ''
suffix: _3
suffix: _C3
tone_ranges:
- B2-C#4
- color: Whisper
Expand Down
48 changes: 36 additions & 12 deletions OpenUtau.Test/Plugins/EnArpaPlusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ protected override Phonemizer CreatePhonemizer() {

[Theory]
[InlineData("en_arpa-plus",
new string[] { "good", "morning" },
new string[] { "C4", "C4" },
new string[] { "good", "morning", },
new string[] { "A#3", "A#3" },
new string[] { "", "" },
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" })]
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" })]
[InlineData("en_arpa-plus",
new string[] { "good", "morning" },
new string[] { "A3", "F4" },
new string[] { "C3", "C3" },
new string[] { "", "" },
new string[] { "- g_3", "g uh_3", "uh d_3", "d m_3", "m ao", "ao r", "r n", "n ih", "ih ng", "ng -" })]
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" })]
public void PhonemizeTest(string singerName, string[] lyrics, string[] tones, string[] colors, string[] aliases) {
RunPhonemizeTest(singerName, lyrics, RepeatString(lyrics.Length, ""), tones, colors, aliases);
}
Expand All @@ -32,7 +32,7 @@ public void ColorTest() {
new NoteParams {
lyric = "hi",
hint = "",
tone = "C4",
tone = "A#3",
phonemes = new PhonemeParams[] {
new PhonemeParams {
alt = 0,
Expand All @@ -51,17 +51,41 @@ public void ColorTest() {
}
}
}
}, new string[] { "- hh_3", "hh ay_W", "ay -_3" });
}, new string[] { "- hh_C3", "hh ay_W", "ay -_C3" });
}
public void SyllableTest(string lyric, string hint, string[] aliases) {
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "") } }, aliases);
}
[Theory]
[InlineData("read", "", new string[] { "- r_C3", "r eh_C3", "eh d_C3", "d -_C3" })]
[InlineData("read", "r iy d", new string[] { "- r_C3", "r iy_C3", "iy d_C3", "d -_C3" })]

[InlineData("asdfjkl", "r iy d", new string[] { "- r_C3", "r iy_C3", "iy d_C3", "d -_C3" })]
[InlineData("", "r iy d", new string[] { "- r_C3", "r iy_C3", "iy d_C3", "d -_C3" })]

public void SyllableExternalEndingTest(string lyric, string hint, string[] aliases) {
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "") } }, aliases);
}
[Theory]
[InlineData("more", "m aor", new string[] { "- m_C3", "m ao_C3", "ao r_C3", "r -_C3" })]
[InlineData("'a", "q ax hh", new string[] { "- q_C3", "q ax_C3", "ax hh_C3", "hh -_C3" })]

public void SyllableCCVTest(string lyric, string hint, string[] aliases) {
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "") } }, aliases);
}
[Theory]
[InlineData("trusting", "", new string[] { "- tr_C3", "tr ah_C3", "ah st_C3", "st ih_C3", "ih ng_C3", "ng -_C3" })]
[InlineData("drive", "", new string[] { "- dr_C3", "dr ay_C3", "ay v_C3", "v -_C3" })]

public void SyllableFallbackTest(string lyric, string hint, string[] aliases) {
RunPhonemizeTest("en_arpa-plus", new NoteParams[] { new NoteParams { lyric = lyric, hint = hint, tone = "C3", phonemes = SamePhonemeParams(4, 0, 0, "") } }, aliases);
}
[Theory]
[InlineData("read", "", new string[] { "- r_3", "r eh_3", "eh d_3", "d -_3" })]
[InlineData("read", "r iy d", new string[] { "- r_3", "r iy_3", "iy d_3", "d -_3" })]
[InlineData("kroidroi", "", new string[] { "- kr_C3", "kr oy_C3", "iy dr_C3", "dr oy_C3", "oy -_C3" })]
[InlineData("whhat", "", new string[] { "- hh_C3", "hh uw_C3", "w ah_C3", "ah t_C3", "t -_C3" })]

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