|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | | -using Microsoft.ML.OnnxRuntime; |
5 | | -using OpenUtau.Api; |
6 | | - |
7 | | -namespace OpenUtau.Core.G2p { |
8 | | - public class ItalianG2p : G2pPack { |
9 | | - private static readonly string[] graphemes = new string[] { |
10 | | - "", "", "", "", "\'", "a", "b", "c", "d", "e", |
11 | | - "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", |
12 | | - "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", |
13 | | - "à", "é", "è", "È", "í", "ì", "ò", "ú", "ù", |
14 | | - }; |
15 | | - |
16 | | - private static readonly string[] phonemes = new string[] { |
17 | | - "", "", "", "", "a", "a1", "b", "d", "dz", "dZZ", "e", "e1", "EE", "f", |
18 | | - "g", "i", "i1", "JJ", "k", "l", "LL", "m", "n", "nf", "ng", "o", "o1", |
19 | | - "OO", "p", "r", "rr", "s", "SS", "t", "ts", "tSS", "u", "u1", "v", "w", |
20 | | - "y", "z", |
21 | | - }; |
22 | | - |
23 | | - private static object lockObj = new object(); |
24 | | - private static Dictionary<string, int> graphemeIndexes; |
25 | | - private static IG2p dict; |
26 | | - private static InferenceSession session; |
27 | | - private static Dictionary<string, string[]> predCache = new Dictionary<string, string[]>(); |
28 | | - |
29 | | - public ItalianG2p() { |
30 | | - lock (lockObj) { |
31 | | - if (graphemeIndexes == null) { |
32 | | - graphemeIndexes = graphemes |
33 | | - .Skip(4) |
34 | | - .Select((g, i) => Tuple.Create(g, i)) |
35 | | - .ToDictionary(t => t.Item1, t => t.Item2 + 4); |
36 | | - var tuple = LoadPack(Data.Resources.g2p_it); |
37 | | - dict = tuple.Item1; |
38 | | - session = tuple.Item2; |
39 | | - } |
40 | | - } |
41 | | - GraphemeIndexes = graphemeIndexes; |
42 | | - Phonemes = phonemes; |
43 | | - Dict = dict; |
44 | | - Session = session; |
45 | | - PredCache = predCache; |
46 | | - } |
47 | | - } |
48 | | -} |
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using Microsoft.ML.OnnxRuntime; |
| 5 | +using OpenUtau.Api; |
| 6 | + |
| 7 | +namespace OpenUtau.Core.G2p { |
| 8 | + public class ItalianG2p : G2pPack { |
| 9 | + private static readonly string[] graphemes = new string[] { |
| 10 | + "", "", "", "", "\'", "a", "b", "c", "d", "e", |
| 11 | + "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", |
| 12 | + "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", |
| 13 | + "à", "é", "è", "È", "í", "ì", "ò", "ú", "ù", |
| 14 | + }; |
| 15 | + |
| 16 | + private static readonly string[] phonemes = new string[] { |
| 17 | + "", "", "", "", "a", "a1", "b", "d", "dz", "dZZ", "e", "e1", "EE", "f", |
| 18 | + "g", "i", "i1", "JJ", "k", "l", "LL", "m", "n", "nf", "ng", "o", "o1", |
| 19 | + "OO", "p", "r", "rr", "s", "SS", "t", "ts", "tSS", "u", "u1", "v", "w", |
| 20 | + "y", "z", |
| 21 | + }; |
| 22 | + |
| 23 | + private static object lockObj = new object(); |
| 24 | + private static Dictionary<string, int> graphemeIndexes; |
| 25 | + private static IG2p dict; |
| 26 | + private static InferenceSession session; |
| 27 | + private static Dictionary<string, string[]> predCache = new Dictionary<string, string[]>(); |
| 28 | + |
| 29 | + public ItalianG2p() { |
| 30 | + lock (lockObj) { |
| 31 | + if (graphemeIndexes == null) { |
| 32 | + graphemeIndexes = graphemes |
| 33 | + .Skip(4) |
| 34 | + .Select((g, i) => Tuple.Create(g, i)) |
| 35 | + .ToDictionary(t => t.Item1, t => t.Item2 + 4); |
| 36 | + var tuple = LoadPack(Data.Resources.g2p_it); |
| 37 | + dict = tuple.Item1; |
| 38 | + session = tuple.Item2; |
| 39 | + } |
| 40 | + } |
| 41 | + GraphemeIndexes = graphemeIndexes; |
| 42 | + Phonemes = phonemes; |
| 43 | + Dict = dict; |
| 44 | + Session = session; |
| 45 | + PredCache = predCache; |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments