Skip to content

Commit

Permalink
Merge pull request #783 from The-UTAU-Black-Supermarket/en-to-ja-tests
Browse files Browse the repository at this point in the history
EN to JA test suite and fixes
  • Loading branch information
stakira authored Jul 28, 2023
2 parents db972e4 + d2d4494 commit 72d38e1
Show file tree
Hide file tree
Showing 6 changed files with 331 additions and 18 deletions.
6 changes: 5 additions & 1 deletion OpenUtau.Plugin.Builtin/ENtoJAPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,19 @@ protected override List<string> ProcessEnding(Ending ending) {
cons = "r";
} else if (cons == "ly") {
cons = "ry";
} else {
cons = StartingConsonant[cons];
}

var vc = $"{vowel} {cons}";
var altVc = $"{vowel} {cons[0]}";

if (HasOto(vc, tone)) {
phonemes.Add(vc);
} else if (HasOto(altVc, tone)) {
phonemes.Add(altVc);
} else {
return (false, new string[0]);
}

if (affricates.Contains(cons) && cc > 1) {
Expand Down
1 change: 1 addition & 0 deletions OpenUtau.Test/Files/ja_cv/character.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name=ja_cv
1 change: 1 addition & 0 deletions OpenUtau.Test/Files/ja_cv/character.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
text_file_encoding: shift_jis
102 changes: 102 additions & 0 deletions OpenUtau.Test/Files/ja_cv/oto.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
audio.wav=あ,0,0,0,0,0
audio.wav=い,0,0,0,0,0
audio.wav=う,0,0,0,0,0
audio.wav=え,0,0,0,0,0
audio.wav=お,0,0,0,0,0
audio.wav=か,0,0,0,0,0
audio.wav=き,0,0,0,0,0
audio.wav=く,0,0,0,0,0
audio.wav=け,0,0,0,0,0
audio.wav=こ,0,0,0,0,0
audio.wav=きゃ,0,0,0,0,0
audio.wav=きゅ,0,0,0,0,0
audio.wav=きょ,0,0,0,0,0
audio.wav=が,0,0,0,0,0
audio.wav=ぎ,0,0,0,0,0
audio.wav=ぐ,0,0,0,0,0
audio.wav=げ,0,0,0,0,0
audio.wav=ご,0,0,0,0,0
audio.wav=ぎゃ,0,0,0,0,0
audio.wav=ぎゅ,0,0,0,0,0
audio.wav=ぎょ,0,0,0,0,0
audio.wav=さ,0,0,0,0,0
audio.wav=し,0,0,0,0,0
audio.wav=す,0,0,0,0,0
audio.wav=せ,0,0,0,0,0
audio.wav=そ,0,0,0,0,0
audio.wav=しゃ,0,0,0,0,0
audio.wav=しゅ,0,0,0,0,0
audio.wav=しょ,0,0,0,0,0
audio.wav=ざ,0,0,0,0,0
audio.wav=じ,0,0,0,0,0
audio.wav=ず,0,0,0,0,0
audio.wav=ぜ,0,0,0,0,0
audio.wav=ぞ,0,0,0,0,0
audio.wav=じゃ,0,0,0,0,0
audio.wav=じゅ,0,0,0,0,0
audio.wav=じょ,0,0,0,0,0
audio.wav=た,0,0,0,0,0
audio.wav=ち,0,0,0,0,0
audio.wav=つ,0,0,0,0,0
audio.wav=て,0,0,0,0,0
audio.wav=と,0,0,0,0,0
audio.wav=ちゃ,0,0,0,0,0
audio.wav=ちゅ,0,0,0,0,0
audio.wav=ちょ,0,0,0,0,0
audio.wav=だ,0,0,0,0,0
audio.wav=で,0,0,0,0,0
audio.wav=ど,0,0,0,0,0
audio.wav=な,0,0,0,0,0
audio.wav=に,0,0,0,0,0
audio.wav=ぬ,0,0,0,0,0
audio.wav=ね,0,0,0,0,0
audio.wav=の,0,0,0,0,0
audio.wav=にゃ,0,0,0,0,0
audio.wav=にゅ,0,0,0,0,0
audio.wav=にょ,0,0,0,0,0
audio.wav=は,0,0,0,0,0
audio.wav=ひ,0,0,0,0,0
audio.wav=ふ,0,0,0,0,0
audio.wav=へ,0,0,0,0,0
audio.wav=ほ,0,0,0,0,0
audio.wav=ひゃ,0,0,0,0,0
audio.wav=ひゅ,0,0,0,0,0
audio.wav=ひょ,0,0,0,0,0
audio.wav=ば,0,0,0,0,0
audio.wav=び,0,0,0,0,0
audio.wav=ぶ,0,0,0,0,0
audio.wav=べ,0,0,0,0,0
audio.wav=ぼ,0,0,0,0,0
audio.wav=びゃ,0,0,0,0,0
audio.wav=びゅ,0,0,0,0,0
audio.wav=びょ,0,0,0,0,0
audio.wav=ぱ,0,0,0,0,0
audio.wav=ぴ,0,0,0,0,0
audio.wav=ぷ,0,0,0,0,0
audio.wav=ぺ,0,0,0,0,0
audio.wav=ぽ,0,0,0,0,0
audio.wav=ぴゃ,0,0,0,0,0
audio.wav=ぴゅ,0,0,0,0,0
audio.wav=ぴょ,0,0,0,0,0
audio.wav=ま,0,0,0,0,0
audio.wav=み,0,0,0,0,0
audio.wav=む,0,0,0,0,0
audio.wav=め,0,0,0,0,0
audio.wav=も,0,0,0,0,0
audio.wav=みゃ,0,0,0,0,0
audio.wav=みゅ,0,0,0,0,0
audio.wav=みょ,0,0,0,0,0
audio.wav=や,0,0,0,0,0
audio.wav=ゆ,0,0,0,0,0
audio.wav=よ,0,0,0,0,0
audio.wav=ら,0,0,0,0,0
audio.wav=り,0,0,0,0,0
audio.wav=る,0,0,0,0,0
audio.wav=れ,0,0,0,0,0
audio.wav=ろ,0,0,0,0,0
audio.wav=りゃ,0,0,0,0,0
audio.wav=りゅ,0,0,0,0,0
audio.wav=りょ,0,0,0,0,0
audio.wav=わ,0,0,0,0,0
audio.wav=を,0,0,0,0,0
audio.wav=ん,0,0,0,0,0
5 changes: 5 additions & 0 deletions OpenUtau.Test/Files/ja_cv/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DO NOT add oto.ini entries to this voicebank.
This is used for automated tests of voicebanks with absolutely 0 extra samples.

oto.ini�ɉ����Ȃ��ł��������B
���̉����͗]���ȋL�����Ȃ��e�X�g�̂��߂ɑ��݂��܂��B
234 changes: 217 additions & 17 deletions OpenUtau.Test/Plugins/EnToJaTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Xml.Linq;
using System;
using OpenUtau.Api;
using OpenUtau.Plugin.Builtin;
using Xunit;
Expand All @@ -12,36 +14,234 @@ protected override Phonemizer CreatePhonemizer() {

[Theory]
[InlineData("ja_cvvc",
new string[] { "test", "words" },
new string[] { "", "", },
new string[] { "C3", "C3" },
new string[] { "", "", },
new string[] { "て_A3", "e s_A3", "と_A3", "うぉ_A3", "o d_A3", "ず_A3" })]
public void BasicPhonemizingTest(string singerName, string[] lyrics, string[] alts, string[] tones, string[] colors, string[] aliases) {
RunPhonemizeTest(singerName, lyrics, alts, tones, colors, aliases);
new string[] { "て_C4", "e s_C4", "と_C4", "うぉ_C4", "o d_C4", "ず_C4" })]
[InlineData("ja_vcv",
new string[] { "- てA3", "e すA3", "u とA3", "o うぉA3", "o どA3", "o ずA3" })]
[InlineData("ja_cv",
new string[] { "", "", "", "", "", "" })]
public void BasicPhonemizingTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "test", "words" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "test", "words" },
new string[] { "", "", },
new string[] { "C3", "C4" },
new string[] { "", "", },
new string[] { "て_A3", "e s_A3", "と_A3", "うぉ_C4", "o d_C4", "ず_C4" })]
public void MultipitchTest(string singerName, string[] lyrics, string[] alts, string[] tones, string[] colors, string[] aliases) {
RunPhonemizeTest(singerName, lyrics, alts, tones, colors, aliases);
[InlineData("ja_vcv",
new string[] { "C4", "C5" },
new string[] { "- てA3", "e すA3", "u とA3", "o うぉC5", "o どC5", "o ずC5" })]
public void MultipitchTest(string singerName, string[] tones, string[] aliases) {
RunPhonemizeTest(singerName, new string[] { "test", "words" },
RepeatString(2, ""), tones, RepeatString(2, ""), aliases);
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "test", "words" },
new string[] { "", "", },
new string[] { "C4", "C4" },
new string[] { "", "", },
new string[] { "て_C4", "e s_強B3", "と_C4", "うぉ_C4", "o d_C4", "ず_C4" })]
[InlineData("ja_vcv",
new string[] { "", "Clear", },
new string[] { "- てA3", "e すCA3", "u とA3", "o うぉA3", "o どA3", "o ずA3" })]
// Colors are per-phoneme
public void VoiceColorTest(string singerName, string[] lyrics, string[] alts, string[] tones, string[] colors, string[] aliases) {
RunPhonemizeTest(singerName, lyrics, alts, tones, colors, aliases);
public void VoiceColorTest(string singerName, string[] colors, string[] aliases) {
RunPhonemizeTest(singerName, new string[] { "test", "words" },
RepeatString(2, ""), RepeatString(2, "C4"), colors, aliases);
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "て_C4", "e s_C4", "て_C4", "e n_C4" })]
[InlineData("ja_vcv",
new string[] { "- てA3", "e すA3", "u てA3", "e んA3", "n RA3" })]
[InlineData("ja_cv",
new string[] { "", "", "", "" })]
// Should have one て only, not become てえ
public void SyllableExtendTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "testing", "+*", "+", "+" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "- お_C4", "o ry_C4", "りゅ_C4", "u ky_C4", "きゅ_C4", "u ts_C4", "つ_C4", "u n_C4" })]
[InlineData("ja_vcv",
new string[] { "- おA3", "o りゅA3", "u きゅA3", "u つA3", "u んA3", "n RA3" })]
[InlineData("ja_cv",
new string[] { "", "りゅ", "きゅ", "", "" })]
public void SyllableSpecialClusterTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "all", "you", "cute", "soon" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "- あ_C4", "a s_C4", "た_C4", "a w_C4" })]
[InlineData("ja_vcv",
new string[] { "- あA3", "a すA3", "u たA3", "a うA3" })]
[InlineData("ja_cv",
new string[] { "", "", "", "" })]
public void SyllableClusterTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "a", "star" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "ヴ_C4" })]
[InlineData("ja_vcv",
new string[] { "- ヴA3", "u RA3" })]
[InlineData("ja_cv",
new string[] { "" })]
public void SyllableConditionalAltTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "vu" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "てぃ_C4" })]
[InlineData("ja_vcv",
new string[] { "- てぃA3", "i RA3" })]
[InlineData("ja_cv",
new string[] { "", "" })]
public void SyllableExtraCvTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "tea" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "- あ_C4" })]
[InlineData("ja_vcv",
new string[] { "- あA3", "a RA3" })]
[InlineData("ja_cv",
new string[] { "" })]
public void EndingVowelTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "a" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "- え_C4", "e n_C4" })]
[InlineData("ja_vcv",
new string[] { "- えA3", "e んA3", "n RA3" })]
[InlineData("ja_cv",
new string[] { "", "" })]
public void EndingNasalTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "an" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "ば_C4", "a w_C4", "- ん_C4" })]
[InlineData("ja_vcv",
new string[] { "- ばA3", "a うA3", "u んA3", "n RA3" })]
[InlineData("ja_cv",
new string[] { "", "", "" })]
public void EndingClusterNasalTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "barn" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "- あ_C4", "a p_C4" })]
[InlineData("ja_vcv",
new string[] { "- あA3", "a ぷA3" })]
[InlineData("ja_cv",
new string[] { "", "" })]
public void EndingSingleConsonantTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "up" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "- あ_C4", "a v_C4" })]
[InlineData("ja_vcv",
new string[] { "- あA3", "a ヴA3" })]
[InlineData("ja_cv",
new string[] { "", "" })]
public void EndingConditionalAltTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "of" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "- あ_C4", "a n_C4", "ど_C4" })]
[InlineData("ja_vcv",
new string[] { "- あA3", "a んA3", "n どA3" })]
[InlineData("ja_cv",
new string[] { "", "", "" })]
public void EndingClusterTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "and" });
}

[Theory]
[InlineData("ja_cvvc",
new string[] { "- え_C4", "e ts_C4", "つ_C4" })]
[InlineData("ja_vcv",
new string[] { "- えA3", "e つA3" })]
[InlineData("ja_cv",
new string[] { "", "" })]
public void EndingSpecialClusterTest(string singerName, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases,
new string[] { "its" });
}

[Theory]
[InlineData("ja_vcv",
new string[] { "its", "its" },
new string[] { "- えA3", "e つぇA3", "e つA3" })]
[InlineData("ja_vcv",
new string[] { "itch", "itch" },
new string[] { "- えA3", "e ちぇA3", "e ちゅA3" })]
[InlineData("ja_vcv",
new string[] { "age", "age" },
new string[] { "- えA3", "e いA3", "i じぇA3", "e いA3", "i じゅA3" })]
public void EndingVcvAffricateTest(string singerName, string[] lyrics, string[] aliases) {
SameAltsTonesColorsTest(singerName, aliases, lyrics);
}

[Theory]
[InlineData(
new string[] { "a", "the" },
new string[] { "- あ_C4", "a d_C4", "だ_C4" })]
[InlineData(
new string[] { "a", "thin" },
new string[] { "- あ_C4", "a s_C4", "せ_C4", "e n_C4" })]
[InlineData(
new string[] { "a", "zha" },
new string[] { "- あ_C4", "a sh_C4", "しゃ_C4" })]
[InlineData(
new string[] { "a", "ra" },
new string[] { "- あ_C4", "a w_C4", "わ_C4" })]
[InlineData(
new string[] { "a", "la" },
new string[] { "- あ_C4", "a r_C4", "ら_C4" })]
[InlineData(
new string[] { "all", "you" },
new string[] { "- お_C4", "o ry_C4", "りゅ_C4" })]
public void SyllableDigraphVCTest(string[] lyrics, string[] aliases) {
SameAltsTonesColorsTest("ja_cvvc", aliases, lyrics);
}

private void SameAltsTonesColorsTest(string singerName, string[] aliases, string[] lyrics) {
RunPhonemizeTest(singerName, lyrics,
RepeatString(lyrics.Length, ""),
RepeatString(lyrics.Length, "C4"),
RepeatString(lyrics.Length, ""), aliases);
}

private string[] RepeatString(int count, string s) {
string[] array = new string[count];
Array.Fill(array, s);
return array;
}
}
}

0 comments on commit 72d38e1

Please sign in to comment.