-
Notifications
You must be signed in to change notification settings - Fork 286
/
FrenchG2p.cs
49 lines (45 loc) · 1.9 KB
/
FrenchG2p.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.ML.OnnxRuntime;
using OpenUtau.Api;
namespace OpenUtau.Core.G2p {
public class FrenchG2p : 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[] {
"", "", "", "", "aa", "ai", "an", "au", "bb", "ch", "dd",
"ee", "ei", "eu", "ff", "gg", "gn", "ii", "in", "jj", "kk",
"ll", "mm", "nn", "oe", "on", "oo", "ou", "pp", "rr", "ss",
"tt", "un", "uu", "uy", "vv", "ww", "yy", "zz"
};
private static object lockObj = new object();
private static Dictionary<string, int> graphemeIndexes;
private static IG2p dict;
private static InferenceSession session;
private static Dictionary<string, string[]> predCache = new Dictionary<string, string[]>();
public FrenchG2p() {
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_fr);
dict = tuple.Item1;
session = tuple.Item2;
}
}
GraphemeIndexes = graphemeIndexes;
Phonemes = phonemes;
Dict = dict;
Session = session;
PredCache = predCache;
}
}
}