diff --git a/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerFilipinoPhonemizer.cs b/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerFilipinoPhonemizer.cs new file mode 100644 index 000000000..4fed84789 --- /dev/null +++ b/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerFilipinoPhonemizer.cs @@ -0,0 +1,22 @@ +using OpenUtau.Api; +using OpenUtau.Core.G2p; + +namespace OpenUtau.Core.DiffSinger +{ + [Phonemizer("DiffSinger Filipino Phonemizer", "DIFFS FIL", language: "FIL", author: "julieraptor")] + public class DiffSingerFilipinoPhonemizer : DiffSingerG2pPhonemizer + { + protected override string GetDictionaryName()=>"dsdict-fil.yaml"; + public override string GetLangCode()=>"fil"; + protected override IG2p LoadBaseG2p() => new FilipinoG2p(); + protected override string[] GetBaseG2pVowels() => new string[] { + "a", "e", "i", "o", "u" + }; + + protected override string[] GetBaseG2pConsonants() => new string[] { + "q", "b", "d", "dy", "f", "g", "H", "hh", "j", "k", "l", + "m", "n", "ng", "ny", "p", "dx", "s", "sy", "t", "th", + "ch", "v", "w", "z" + }; + } +} diff --git a/OpenUtau.Core/G2p/Data/Resources.Designer.cs b/OpenUtau.Core/G2p/Data/Resources.Designer.cs index c3b140915..605603c89 100644 --- a/OpenUtau.Core/G2p/Data/Resources.Designer.cs +++ b/OpenUtau.Core/G2p/Data/Resources.Designer.cs @@ -110,6 +110,16 @@ internal static byte[] g2p_es { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] g2p_fil { + get { + object obj = ResourceManager.GetObject("g2p-fil", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// diff --git a/OpenUtau.Core/G2p/Data/Resources.resx b/OpenUtau.Core/G2p/Data/Resources.resx index 0ef164ba7..062f69fb8 100644 --- a/OpenUtau.Core/G2p/Data/Resources.resx +++ b/OpenUtau.Core/G2p/Data/Resources.resx @@ -130,6 +130,9 @@ g2p-es.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + g2p-fil.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + g2p-fr.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 diff --git a/OpenUtau.Core/G2p/Data/g2p-fil.zip b/OpenUtau.Core/G2p/Data/g2p-fil.zip new file mode 100644 index 000000000..65b76a2c8 Binary files /dev/null and b/OpenUtau.Core/G2p/Data/g2p-fil.zip differ diff --git a/OpenUtau.Core/G2p/FilipinoG2p.cs b/OpenUtau.Core/G2p/FilipinoG2p.cs new file mode 100644 index 000000000..af5addd18 --- /dev/null +++ b/OpenUtau.Core/G2p/FilipinoG2p.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.ML.OnnxRuntime; +using OpenUtau.Api; + +namespace OpenUtau.Core.G2p { + public class FilipinoG2p : G2pPack { + private static readonly string[] graphemes = new string[] { + "", "", "", "", "\'", "-", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", + "u", "v", "w", "x", "y", "z", "ñ" + }; + + private static readonly string[] phonemes = new string[] { + "", "", "", "", "a", "b", "d", "dx", "dy", "e", "f", "g", "h", "hh", "i", + "j", "k", "l", "m", "n", "ng", "ny", "o", "p", "q", "s", + "sy", "t", "th", "ts", "u", "v", "w", "z" + }; + + private static object lockObj = new object(); + private static Dictionary graphemeIndexes; + private static IG2p dict; + private static InferenceSession session; + private static Dictionary predCache = new Dictionary(); + + public FilipinoG2p() { + lock (lockObj) { + if (graphemeIndexes == null) { + graphemeIndexes = graphemes + .Skip(4) + .Select((g, i) => Tuple.Create(g, i)) + .ToDictionary(t => t.Item1, t => t.Item2 + 4); + var tuple = LoadPack(Data.Resources.g2p_fil, + s => s.ToLowerInvariant(), + s => RemoveTailDigits(s.ToLowerInvariant())); + dict = tuple.Item1; + session = tuple.Item2; + } + } + GraphemeIndexes = graphemeIndexes; + Phonemes = phonemes; + Dict = dict; + Session = session; + PredCache = predCache; + } + } +} diff --git a/OpenUtau.Core/Util/LyricsHelper.cs b/OpenUtau.Core/Util/LyricsHelper.cs index 6f829b6f0..b34a34259 100644 --- a/OpenUtau.Core/Util/LyricsHelper.cs +++ b/OpenUtau.Core/Util/LyricsHelper.cs @@ -38,6 +38,7 @@ public Type GetPreferred() { typeof(JyutpingLyricsHelper), typeof(ArpabetG2pLyricsHelper), typeof(ArpabetPlusG2pLyricsHelper), + typeof(FilipinoG2pLyricsHelper), typeof(FrenchG2pLyricsHelper), typeof(FrenchMillefeuilleG2pLyricsHelper), typeof(GermanG2pLyricsHelper), @@ -93,6 +94,9 @@ public class ArpabetPlusG2pLyricsHelper : G2pLyricsHelper { public ArpabetPlusG2pLyricsHelper() : base(new ArpabetPlusG2p()) { } } + public class FilipinoG2pLyricsHelper : G2pLyricsHelper { + public FilipinoG2pLyricsHelper() : base(new FilipinoG2p()) { } + } public class FrenchG2pLyricsHelper : G2pLyricsHelper { public FrenchG2pLyricsHelper() : base(new FrenchG2p()) { } } diff --git a/OpenUtau/ViewModels/PhoneticAssistantViewModel.cs b/OpenUtau/ViewModels/PhoneticAssistantViewModel.cs index cd221b9db..c0ec317a7 100644 --- a/OpenUtau/ViewModels/PhoneticAssistantViewModel.cs +++ b/OpenUtau/ViewModels/PhoneticAssistantViewModel.cs @@ -36,6 +36,7 @@ public G2pOption(Type klass) { new G2pOption(typeof(RussianG2p)), new G2pOption(typeof(SpanishG2p)), new G2pOption(typeof(KoreanG2p)), + new G2pOption(typeof(FilipinoG2p)), }; private Api.G2pPack? g2p;