예제 #1
0
 private void LoadSingerDict()
 {
     if (singer != null && singer.Loaded)
     {
         string file = Path.Combine(singer.Location, "arpasing.yaml");
         if (File.Exists(file))
         {
             try {
                 singerDict = G2pDictionary.NewBuilder().Load(File.ReadAllText(file)).Build();
             } catch (Exception e) {
                 Log.Error(e, $"Failed to load {file}");
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Initializes the CMUdict.
        /// </summary>
        private void Initialize()
        {
            // Load cmudict.
            cmudict = G2pDictionary.GetShared("cmudict");
            // Load g2p plugin dictionary.
            string filepath = Path.Combine(Path.GetDirectoryName(typeof(ArpasingPhonemizer).Assembly.Location), "arpasing.yaml");

            try {
                CreateDefaultPluginDict(filepath);
                if (File.Exists(filepath))
                {
                    pluginDict = G2pDictionary.NewBuilder().Load(File.ReadAllText(filepath)).Build();
                }
            } catch (Exception e) {
                Log.Error(e, $"Failed to load {filepath}");
            }
            // Load g2p singer dictionary.
            LoadSingerDict();
            mergedG2p = new G2pFallbacks(new IG2p[] { pluginDict, singerDict, cmudict }.OfType <IG2p>().ToArray());
            // Arpasing voicebanks are often incomplete. A fallback table is used to slightly improve the situation.
            vowelFallback = "aa=ah,ae;ae=ah,aa;ah=aa,ae;ao=ow;ow=ao;eh=ae;ih=iy;iy=ih;uh=uw;uw=uh;aw=ao".Split(';')
                            .Select(entry => entry.Split('='))
                            .ToDictionary(parts => parts[0], parts => parts[1].Split(','));
        }