diff --git a/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerThaiPhonemizer.cs b/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerThaiPhonemizer.cs
new file mode 100644
index 000000000..bde121119
--- /dev/null
+++ b/OpenUtau.Core/DiffSinger/Phonemizers/DiffSingerThaiPhonemizer.cs
@@ -0,0 +1,22 @@
+using OpenUtau.Api;
+using OpenUtau.Core.G2p;
+
+namespace OpenUtau.Core.DiffSinger
+{
+ [Phonemizer("DiffSinger Thai Phonemizer", "DIFFS TH", language: "TH")]
+ public class DiffSingerThaiPhonemizer : DiffSingerG2pPhonemizer {
+ protected override string GetDictionaryName() => "dsdict-th.yaml";
+ public override string GetLangCode() => "th";
+ protected override IG2p LoadBaseG2p() => new ThaiG2p();
+ protected override string[] GetBaseG2pVowels() => new string[] {
+ "a", "i", "u", "e", "o", "A", "O", "E",
+ "Ua", "U", "ia", "ua", "I", "au"
+ };
+
+ protected override string[] GetBaseG2pConsonants() => new string[] {
+ "b", "ch", "d", "f", "h", "j", "k", "kk", "l", "m",
+ "n", "ng", "p", "pp", "r", "s", "t", "tt", "w", "W",
+ "y", "Y", "B", "D", "K"
+ };
+ }
+}
diff --git a/OpenUtau.Core/G2p/Data/Resources.Designer.cs b/OpenUtau.Core/G2p/Data/Resources.Designer.cs
index 605603c89..8379332a1 100644
--- a/OpenUtau.Core/G2p/Data/Resources.Designer.cs
+++ b/OpenUtau.Core/G2p/Data/Resources.Designer.cs
@@ -189,5 +189,15 @@ internal static byte[] g2p_ru {
return ((byte[])(obj));
}
}
+
+ ///
+ /// Looks up a localized resource of type System.Byte[].
+ ///
+ internal static byte[] g2p_th {
+ get {
+ object obj = ResourceManager.GetObject("g2p-th", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
}
}
diff --git a/OpenUtau.Core/G2p/Data/Resources.resx b/OpenUtau.Core/G2p/Data/Resources.resx
index 062f69fb8..89892ef18 100644
--- a/OpenUtau.Core/G2p/Data/Resources.resx
+++ b/OpenUtau.Core/G2p/Data/Resources.resx
@@ -154,6 +154,9 @@
g2p-ru.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ g2p-th.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
g2p-arpabet-plus.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
diff --git a/OpenUtau.Core/G2p/Data/g2p-th.zip b/OpenUtau.Core/G2p/Data/g2p-th.zip
new file mode 100644
index 000000000..2985b64f1
Binary files /dev/null and b/OpenUtau.Core/G2p/Data/g2p-th.zip differ
diff --git a/OpenUtau.Core/G2p/ThaiG2p.cs b/OpenUtau.Core/G2p/ThaiG2p.cs
new file mode 100644
index 000000000..ce9f838f5
--- /dev/null
+++ b/OpenUtau.Core/G2p/ThaiG2p.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.ML.OnnxRuntime;
+using OpenUtau.Api;
+
+namespace OpenUtau.Core.G2p {
+ public class ThaiG2p : G2pPack {
+ private static readonly string[] graphemes = new string[] {
+ "", "", "", "", "ก", "ข", "ฃ", "ค", "ฅ", "ฆ", "ง", "จ",
+ "ฉ", "ช", "ซ", "ฌ", "ญ", "ฎ", "ฏ", "ฐ", "ฑ", "ฒ", "ณ",
+ "ด", "ต", "ถ", "ท", "ธ", "น", "บ", "ป", "ผ", "ฝ", "พ", "ฟ",
+ "ภ", "ม", "ย", "ร", "ฤ", "ล", "ฦ", "ว", "ศ", "ษ", "ส", "ห",
+ "ฬ", "อ", "ฮ", "ฯ", "ะ", "ั", "า", "ำ", "ิ", "ี", "ึ", "ื",
+ "ุ", "ู", "ฺ", "฿", "เ", "แ", "โ", "ใ", "ไ", "ๅ", "ๆ", "็", "่",
+ "้", "๊", "๋", "์", "ํ", "๎",
+ };
+
+ private static readonly string[] phonemes = new string[] {
+ "", "", "", "", "a", "i", "u", "e", "o", "A", "O", "E",
+ "Ua", "U", "ia", "ua", "I", "au", "b", "ch", "d", "f", "h",
+ "j", "k", "kk", "l", "m", "n", "ng", "p", "pp", "r", "s", "t",
+ "tt", "w", "W", "y", "Y", "B", "D", "K",
+ };
+
+ 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 ThaiG2p() {
+ 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_th);
+ dict = tuple.Item1;
+ session = tuple.Item2;
+ }
+ }
+ GraphemeIndexes = graphemeIndexes;
+ Phonemes = phonemes;
+ Dict = dict;
+ Session = session;
+ PredCache = predCache;
+ }
+ }
+}