diff --git a/TuneLab/TuneLab.csproj b/TuneLab/TuneLab.csproj
index 5527427..efcae92 100644
--- a/TuneLab/TuneLab.csproj
+++ b/TuneLab/TuneLab.csproj
@@ -25,8 +25,8 @@
+
-
diff --git a/TuneLab/Utils/LyricUtils.cs b/TuneLab/Utils/LyricUtils.cs
index 2a377a5..aba062e 100644
--- a/TuneLab/Utils/LyricUtils.cs
+++ b/TuneLab/Utils/LyricUtils.cs
@@ -1,8 +1,6 @@
-using IKg2p;
-using Microsoft.International.Converters.PinYinConverter;
+using Pinyin;
using System.Collections.Generic;
using System.Linq;
-using TuneLab.Base.Structures;
using TuneLab.Base.Utils;
namespace TuneLab.Utils;
@@ -18,11 +16,11 @@ public struct LyricResult
public static List Split(string lyrics)
{
- var g2pResults = ZhG2p.MandarinInstance.Convert(lyrics, false, true);
+ var pinyinResults = Pinyin.Pinyin.Instance.HanziToPinyin(lyrics, ManTone.Style.NORMAL, Error.Default, true, false);
var results = new List();
- foreach (var g2pRes in g2pResults)
+ foreach (var pinyinRes in pinyinResults)
{
- results.Add(new LyricResult() { Lyric = g2pRes.lyric, Pronunciation = g2pRes.syllable/*, Candidates = g2pRes.candidates*/ });
+ results.Add(new LyricResult() { Lyric = pinyinRes.hanzi, Pronunciation = pinyinRes.pinyin/*, Candidates = pinyinRes.candidates*/ });
}
return results;
}
@@ -41,7 +39,7 @@ public static List SplitLyrics(string lyrics)
public static List SplitToWords(string lyric)
{
- return ZhG2p.SplitString(lyric);
+ return Pinyin.ChineseG2p.SplitString(lyric);
}
public static IEnumerable SplitByInvailidChars(string lyric)
@@ -54,7 +52,7 @@ public static IEnumerable SplitByInvailidChars(string lyric)
public static string GetPreferredPronunciation(string lyric)
{
- var pinyins = ZhG2p.MandarinInstance.Convert(lyric, false);
+ var pinyins = Pinyin.Pinyin.Instance.HanziToPinyin(lyric, ManTone.Style.NORMAL, Error.Default, true, false);
if (pinyins.IsEmpty())
return string.Empty;
@@ -62,32 +60,19 @@ public static string GetPreferredPronunciation(string lyric)
if (pinyin.error)
return string.Empty;
- return pinyin.syllable;
+ return pinyin.pinyin;
}
public static IReadOnlyCollection GetPronunciations(string lyric)
{
if (lyric.Length == 1)
{
- var c = lyric[0];
- if (ChineseChar.IsValidChar(c))
+ if (Pinyin.Pinyin.Instance.IsHanzi(lyric))
{
- var chineseChar = new ChineseChar(c);
- return chineseChar.Pinyins.Take(chineseChar.PinyinCount).Convert(ToPinyin).ToHashSet();
+ return Pinyin.Pinyin.Instance.GetDefaultPinyin(lyric, ManTone.Style.NORMAL, false, false);
}
}
return [];
}
-
- static string ToPinyin(string pinyin)
- {
- if (string.IsNullOrEmpty(pinyin))
- return string.Empty;
-
- if (char.IsNumber(pinyin[^1]))
- return pinyin[..^1].ToLower();
-
- return pinyin.ToLower();
- }
}