Ejemplo n.º 1
0
 public Dictionary <string, Voice> GetVoices()
 {
     if (voices.IsNullOrEmpty())
     {
         voices = VoicesBuilder.ParseFile(Directory + Path.DirectorySeparatorChar + Filename, Encoding, voiceNames.Keys);
     }
     return(voices);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 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}");
            }
        }
    }
Ejemplo n.º 5
0
 public Dictionary <string, Voice> GetVoices()
 {
     return(VoicesBuilder.ParseFile(Directory + Path.DirectorySeparatorChar + Filename, Encoding, VoiceNames.Keys));
 }