Skip to content

Commit

Permalink
Merge pull request #1121 from EX3exp/update-ko-phonemizer-util-2
Browse files Browse the repository at this point in the history
Fixed bug in KoreanPhonemizerUtil, KO CBNN Phonemizer
  • Loading branch information
stakira authored May 10, 2024
2 parents 50dfc45 + bca3ce9 commit c451fc1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
3 changes: 1 addition & 2 deletions OpenUtau.Core/KoreanPhonemizerUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using OpenUtau.Classic;
using Serilog;
using static OpenUtau.Api.Phonemizer;
using OpenUtau.Api;

namespace OpenUtau.Core {
/// <summary>
Expand Down Expand Up @@ -372,7 +371,7 @@ private static Hashtable Variate(Hashtable firstCharSeparated, Hashtable nextCha
nextFirstConsonant = "";
}

if ((!firstLastConsonant.Equals("")) && nextFirstConsonant.Equals("") && (!firstLastConsonant.Equals(""))) {
if ((!firstLastConsonant.Equals(" ")) && nextFirstConsonant.Equals("") && (!firstLastConsonant.Equals(""))) {
// 연음 2
nextFirstConsonant = firstLastConsonant;
firstLastConsonant = " ";
Expand Down
25 changes: 15 additions & 10 deletions OpenUtau.Plugin.Builtin/KoreanCBNNPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ private Result ConvertForCBNN(Note[] notes, string[] prevLyric, string[] thisLyr
}
string frontCV;
string batchim;
string VC = $"{thisMidVowelTail} {FIRST_CONSONANTS[nextLyric[0]]}";
string VC = $"{thisMidVowelTail} {FIRST_CONSONANTS[nextLyric[0]]}{MIDDLE_VOWELS[nextLyric[1]][1]}";
string VV = $"{MIDDLE_VOWELS[prevLyric[1]][2]} {thisMidVowelTail}";
string VSv = $"{thisMidVowelTail} {MIDDLE_VOWELS[nextLyric[1]][1]}";
isItNeedsVSv = thisLyric[2] == " " && nextLyric[0] == "" && !PLAIN_VOWELS.Contains(nextLyric[1]) && FindInOto(VSv, note, true) != null;
isItNeedsVC = thisLyric[2] == " " && nextLyric[0] != "" && nextLyric[0] != "null" && FindInOto(VC, note, true) != null;
isItNeedsVC = thisLyric[2] == " " && nextLyric[0] != "" && nextLyric[0] != "null";

frontCV = $"- {CV}";
if (FindInOto(frontCV, note, true) == null) {
Expand All @@ -155,6 +155,15 @@ private Result ConvertForCBNN(Note[] notes, string[] prevLyric, string[] thisLyr
}
}

if (FindInOto(VC, note, true) == null) {
if (VC.EndsWith("w") || VC.EndsWith("y")) {
VC = VC.Substring(0, VC.Length - 1);
}
if (FindInOto(VC, note, true) == null) {
isItNeedsVC = false;
}
}

if (isItNeedsVV) {CV = VV;}


Expand Down Expand Up @@ -214,26 +223,22 @@ private Result ConvertForCBNN(Note[] notes, string[] prevLyric, string[] thisLyr
}


private string HandleEmptyFirstConsonant(string lyric) {
return lyric == " " ? "" : lyric;
}

public override Result ConvertPhonemes(Note[] notes, Note? prev, Note? next, Note? prevNeighbour, Note? nextNeighbour, Note[] prevNeighbours) {
Note note = notes[0];

Hashtable lyrics = KoreanPhonemizerUtil.Variate(prevNeighbour, note, nextNeighbour);
string[] prevLyric = new string[]{ // "ㄴ", "ㅑ", "ㅇ"
HandleEmptyFirstConsonant((string)lyrics[0]),
(string)lyrics[0],
(string)lyrics[1],
(string)lyrics[2]
};
string[] thisLyric = new string[]{ // "ㄴ", "ㅑ", "ㅇ"
HandleEmptyFirstConsonant((string)lyrics[3]),
(string)lyrics[3],
(string)lyrics[4],
(string)lyrics[5]
};
string[] nextLyric = new string[]{ // "ㄴ", "ㅑ", "ㅇ"
HandleEmptyFirstConsonant((string)lyrics[6]),
(string)lyrics[6],
(string)lyrics[7],
(string)lyrics[8]
};
Expand All @@ -257,7 +262,7 @@ public override Result GenerateEndSound(Note[] notes, Note? prev, Note? next, No
Hashtable lyrics = KoreanPhonemizerUtil.Separate(prevNeighbour_.lyric);

string[] prevLyric = new string[]{ // "ㄴ", "ㅑ", "ㅇ"
HandleEmptyFirstConsonant((string)lyrics[0]),
(string)lyrics[0],
(string)lyrics[1],
(string)lyrics[2]
};
Expand Down
12 changes: 4 additions & 8 deletions OpenUtau.Plugin.Builtin/KoreanCVPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,22 @@ private Result ConvertForCV(Note[] notes, string[] prevLyric, string[] thisLyric
}


private string HandleEmptyFirstConsonant(string lyric) {
return lyric == " " ? "" : lyric;
}

public override Result ConvertPhonemes(Note[] notes, Note? prev, Note? next, Note? prevNeighbour, Note? nextNeighbour, Note[] prevNeighbours) {
Note note = notes[0];

Hashtable lyrics = KoreanPhonemizerUtil.Variate(prevNeighbour, note, nextNeighbour);
string[] prevLyric = new string[]{ // "ㄴ", "ㅑ", "ㅇ"
HandleEmptyFirstConsonant((string)lyrics[0]),
(string)lyrics[0],
(string)lyrics[1],
(string)lyrics[2]
};
string[] thisLyric = new string[]{ // "ㄴ", "ㅑ", "ㅇ"
HandleEmptyFirstConsonant((string)lyrics[3]),
(string)lyrics[3],
(string)lyrics[4],
(string)lyrics[5]
};
string[] nextLyric = new string[]{ // "ㄴ", "ㅑ", "ㅇ"
HandleEmptyFirstConsonant((string)lyrics[6]),
(string)lyrics[6],
(string)lyrics[7],
(string)lyrics[8]
};
Expand All @@ -275,7 +271,7 @@ public override Result GenerateEndSound(Note[] notes, Note? prev, Note? next, No
Hashtable lyrics = KoreanPhonemizerUtil.Separate(prevNeighbour_.lyric);

string[] prevLyric = new string[]{ // "ㄴ", "ㅑ", "ㅇ"
HandleEmptyFirstConsonant((string)lyrics[0]),
(string)lyrics[0],
(string)lyrics[1],
(string)lyrics[2]
};
Expand Down

0 comments on commit c451fc1

Please sign in to comment.