diff --git a/OpenUtau.Core/BaseChinesePhonemizer.cs b/OpenUtau.Core/BaseChinesePhonemizer.cs index 78c57c375..d81c8038e 100644 --- a/OpenUtau.Core/BaseChinesePhonemizer.cs +++ b/OpenUtau.Core/BaseChinesePhonemizer.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Linq; -using IKg2p; using OpenUtau.Api; using OpenUtau.Core.Ustx; +using Pinyin; namespace OpenUtau.Core { public abstract class BaseChinesePhonemizer : Phonemizer { @@ -22,16 +22,15 @@ public static Note[] ChangeLyric(Note[] group, string lyric) { public static string[] Romanize(IEnumerable lyrics) { var lyricsArray = lyrics.ToArray(); var hanziLyrics = lyricsArray - .Where(ZhG2p.MandarinInstance.IsHanzi) + .Where(Pinyin.Pinyin.Instance.IsHanzi) .ToList(); - List g2pResults = ZhG2p.MandarinInstance.Convert(hanziLyrics.ToList(), false, false); - var pinyinResult = g2pResults.Select(res => res.syllable).ToArray(); + var pinyinResult = Pinyin.Pinyin.Instance.HanziToPinyin(hanziLyrics, ManTone.Style.NORMAL, Pinyin.Error.Default, false, false, false).ToStrList(); if (pinyinResult == null) { return lyricsArray; } var pinyinIndex = 0; for (int i = 0; i < lyricsArray.Length; i++) { - if (lyricsArray[i].Length == 1 && ZhG2p.MandarinInstance.IsHanzi(lyricsArray[i])) { + if (lyricsArray[i].Length == 1 && Pinyin.Pinyin.Instance.IsHanzi(lyricsArray[i])) { lyricsArray[i] = pinyinResult[pinyinIndex]; pinyinIndex++; } diff --git a/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerJyutpingPhonemizer.cs b/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerJyutpingPhonemizer.cs index b6d268add..ebe880660 100644 --- a/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerJyutpingPhonemizer.cs +++ b/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerJyutpingPhonemizer.cs @@ -1,16 +1,15 @@ using System.Collections.Generic; using System.Linq; -using IKg2p; using OpenUtau.Api; +using Pinyin; namespace OpenUtau.Core.DiffSinger { [Phonemizer("DiffSinger Jyutping Phonemizer", "DIFFS ZH-YUE", language: "ZH-YUE")] public class DiffSingerJyutpingPhonemizer : DiffSingerBasePhonemizer { protected override string GetDictionaryName() => "dsdict-zh-yue.yaml"; - protected override string GetLangCode()=>"yue"; + protected override string GetLangCode() => "yue"; protected override string[] Romanize(IEnumerable lyrics) { - List g2pResults = ZhG2p.CantoneseInstance.Convert(lyrics.ToList(), false, false); - return g2pResults.Select(res => res.syllable).ToArray(); + return Pinyin.Jyutping.Instance.HanziToPinyin(lyrics.ToList(), CanTone.Style.NORMAL, Pinyin.Error.Default).Select(res => res.pinyin).ToArray(); } } } diff --git a/OpenUtau.Core/OpenUtau.Core.csproj b/OpenUtau.Core/OpenUtau.Core.csproj index 3ee51bdca..5556bdc23 100644 --- a/OpenUtau.Core/OpenUtau.Core.csproj +++ b/OpenUtau.Core/OpenUtau.Core.csproj @@ -10,8 +10,8 @@ + - diff --git a/OpenUtau.Core/Util/LyricsHelper.cs b/OpenUtau.Core/Util/LyricsHelper.cs index f4b9e75b7..55cb5cc54 100644 --- a/OpenUtau.Core/Util/LyricsHelper.cs +++ b/OpenUtau.Core/Util/LyricsHelper.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using IKg2p; using OpenUtau.Api; using OpenUtau.Core.G2p; +using Pinyin; namespace OpenUtau.Core.Util { public interface ILyricsHelper { @@ -58,16 +58,14 @@ public string Convert(string text) { public class PinyinLyricsHelper : ILyricsHelper { public string Source => "汉->han"; public string Convert(string lyric) { - List g2pResults = ZhG2p.MandarinInstance.Convert(lyric, false, true); - return g2pResults.Select(res => res.syllable).ToArray()[0]; + return Pinyin.Pinyin.Instance.GetDefaultPinyin(lyric, ManTone.Style.NORMAL, false, false).ToArray()[0]; } } public class JyutpingLyricsHelper : ILyricsHelper { public string Source => "粤->jyut"; public string Convert(string lyric) { - List g2pResults = ZhG2p.CantoneseInstance.Convert(lyric, false, true); - return g2pResults.Select(res => res.syllable).ToArray()[0]; + return Pinyin.Jyutping.Instance.GetDefaultPinyin(lyric, CanTone.Style.NORMAL).ToArray()[0]; } } diff --git a/OpenUtau.Plugin.Builtin/CantoneseCVVCPhonemizer.cs b/OpenUtau.Plugin.Builtin/CantoneseCVVCPhonemizer.cs index 04af4ae04..19568561a 100644 --- a/OpenUtau.Plugin.Builtin/CantoneseCVVCPhonemizer.cs +++ b/OpenUtau.Plugin.Builtin/CantoneseCVVCPhonemizer.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -using IKg2p; using OpenUtau.Api; +using Pinyin; namespace OpenUtau.Plugin.Builtin { /// @@ -12,8 +12,7 @@ namespace OpenUtau.Plugin.Builtin { [Phonemizer("Cantonese CVVC Phonemizer", "ZH-YUE CVVC", "Lotte V", language: "ZH-YUE")] public class CantoneseCVVCPhonemizer : ChineseCVVCPhonemizer { protected override string[] Romanize(IEnumerable lyrics) { - List g2pResults = ZhG2p.CantoneseInstance.Convert(lyrics.ToList(), false, false); - return g2pResults.Select(res => res.syllable).ToArray(); + return Pinyin.Jyutping.Instance.HanziToPinyin(lyrics.ToList(), CanTone.Style.NORMAL, Pinyin.Error.Default).Select(res => res.pinyin).ToArray(); } } } diff --git a/OpenUtau.Plugin.Builtin/CantoneseSyoPhonemizer.cs b/OpenUtau.Plugin.Builtin/CantoneseSyoPhonemizer.cs index 7812b0def..a70351a96 100644 --- a/OpenUtau.Plugin.Builtin/CantoneseSyoPhonemizer.cs +++ b/OpenUtau.Plugin.Builtin/CantoneseSyoPhonemizer.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Linq; -using IKg2p; using OpenUtau.Api; using OpenUtau.Core.Ustx; +using Pinyin; namespace OpenUtau.Plugin.Builtin { /// @@ -286,16 +286,15 @@ public static Note[] ChangeLyric(Note[] group, string lyric) { public static string[] Romanize(IEnumerable lyrics) { var lyricsArray = lyrics.ToArray(); var hanziLyrics = lyricsArray - .Where(ZhG2p.CantoneseInstance.IsHanzi) + .Where(Pinyin.Jyutping.Instance.IsHanzi) .ToList(); - List g2pResults = ZhG2p.CantoneseInstance.Convert(hanziLyrics.ToList(), false, false); - var jyutpingResult = g2pResults.Select(res => res.syllable).ToArray(); + var jyutpingResult = Pinyin.Jyutping.Instance.HanziToPinyin(hanziLyrics, CanTone.Style.NORMAL, Pinyin.Error.Default).ToStrList(); if (jyutpingResult == null) { return lyricsArray; } var jyutpingIndex = 0; for (int i = 0; i < lyricsArray.Length; i++) { - if (lyricsArray[i].Length == 1 && ZhG2p.CantoneseInstance.IsHanzi(lyricsArray[i])) { + if (lyricsArray[i].Length == 1 && Pinyin.Jyutping.Instance.IsHanzi(lyricsArray[i])) { lyricsArray[i] = jyutpingResult[jyutpingIndex]; jyutpingIndex++; }