示例#1
0
 public Dictionary <string, Voice> GetVoices()
 {
     if (voices.IsNullOrEmpty())
     {
         voices = VoicesBuilder.ParseFile(Directory + Path.DirectorySeparatorChar + Filename, Encoding, voiceNames.Keys);
     }
     return(voices);
 }
示例#2
0
 public IReadOnlyList <Voice> GetVoices()
 {
     if (voices.IsNullOrEmpty())
     {
         string path = Directory + Path.DirectorySeparatorChar + Filename;
         using (new DisposableStopwatch($"Loading voices of {path} took <millis> ms"))
         {
             VoicesBuilder voicesBuilder = new VoicesBuilder(path, Encoding, Relative);
             voices = new List <Voice>(voicesBuilder.GetVoices());
         }
     }
     return(voices);
 }
示例#3
0
    public static Dictionary <string, Voice> GetVoices(SongMeta songMeta)
    {
        string path = songMeta.Directory + Path.DirectorySeparatorChar + songMeta.Filename;

        if (!voicesCache.TryGetValue(path, out CachedVoices cachedVoices))
        {
            using (new DisposableStopwatch($"Loading voices of {path} took <millis> ms"))
            {
                Dictionary <string, Voice> voiceIdentifierToVoiceMap = VoicesBuilder.ParseFile(path, songMeta.Encoding, new List <string>());
                cachedVoices = new CachedVoices(path, voiceIdentifierToVoiceMap);
                voicesCache.Add(path, cachedVoices);
            }
        }
        return(cachedVoices.VoiceIdentifierToVoiceMap);
    }
示例#4
0
    private Voice LoadVoice(SongMeta songMeta, string voiceIdentifier)
    {
        string filePath = songMeta.Directory + Path.DirectorySeparatorChar + songMeta.Filename;

        Debug.Log($"Loading voice of {filePath}");
        Dictionary <string, Voice> voices = VoicesBuilder.ParseFile(filePath, songMeta.Encoding, new List <string>());

        if (string.IsNullOrEmpty(voiceIdentifier))
        {
            return(voices.Values.First());
        }
        else
        {
            if (voices.TryGetValue(voiceIdentifier, out Voice loadedVoice))
            {
                return(loadedVoice);
            }
            else
            {
                throw new Exception($"The song does not contain a voice for {voiceIdentifier}");
            }
        }
    }
示例#5
0
文件: SongMeta.cs 项目: yrandres/Play
 public Dictionary <string, Voice> GetVoices()
 {
     return(VoicesBuilder.ParseFile(Directory + Path.DirectorySeparatorChar + Filename, Encoding, VoiceNames.Keys));
 }