static USinger FromVoicebank(Voicebank voicebank) { var singer = new USinger(); singer.Name = voicebank.Name; singer.Author = voicebank.Author; singer.Website = voicebank.Web; singer.Path = Path.Combine(PathManager.Inst.InstalledSingersPath, Path.GetDirectoryName(voicebank.File)); var imagePath = Path.Combine(singer.Path, voicebank.Image); singer.Avatar = LoadAvatar(imagePath); singer.Loaded = true; singer.PitchMap = voicebank.PrefixMap.Map; foreach (var otoSet in voicebank.OtoSets) { var otoDir = Path.Combine(Path.GetDirectoryName(otoSet.File)); foreach (var oto in otoSet.Otos) { if (!singer.AliasMap.ContainsKey(oto.Name)) { singer.AliasMap.Add(oto.Name, new UOto { Alias = oto.Name, File = Path.Combine(otoDir, oto.Wav), Offset = oto.Offset, Consonant = oto.Consonant, Cutoff = oto.Cutoff, Preutter = oto.Preutter, Overlap = oto.Overlap, }); } } } return(singer); }
public USinger(Voicebank voicebank, string singersPath) { Name = voicebank.Name; Author = voicebank.Author; Web = voicebank.Web; OtherInfo = voicebank.OtherInfo; Location = Path.GetDirectoryName(voicebank.File); if (!string.IsNullOrEmpty(voicebank.Image)) { Avatar = Path.Combine(Location, voicebank.Image); try { using (var stream = new FileStream(Avatar, FileMode.Open)) { using (var memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); AvatarData = memoryStream.ToArray(); } } } catch (Exception e) { AvatarData = null; Log.Error(e, "Failed to load avatar data."); } } if (voicebank.PrefixMap != null) { PrefixMap = voicebank.PrefixMap.Map; } else { PrefixMap = new Dictionary <string, Tuple <string, string> >(); } OtoSets = new List <UOtoSet>(); foreach (var otoSet in voicebank.OtoSets) { OtoSets.Add(new UOtoSet(otoSet, this, singersPath)); } Id = voicebank.Id; Loaded = true; Task.Run(() => { OtoSets .SelectMany(set => set.Otos.Values) .SelectMany(otos => otos) .ToList() .ForEach(oto => { oto.SearchTerms.Add(oto.Alias.ToLowerInvariant().Replace(" ", "")); oto.SearchTerms.Add(WanaKana.ToRomaji(oto.Alias).ToLowerInvariant().Replace(" ", "")); }); }); }
USinger GetDummySinger() { var voicebank = new Voicebank { File = "null", Name = "Dummy", }; var otoSet = new OtoSet { File = "null", Name = "", }; otoSet.Otos.Add(new Oto { Alias = "a", Wav = "a.wav", }); voicebank.OtoSets.Add(otoSet); return(new USinger(voicebank, "null")); }
public USinger(Voicebank voicebank, string singersPath) { Name = voicebank.Name; Author = voicebank.Author; Web = voicebank.Web; Location = Path.Combine(singersPath, Path.GetDirectoryName(voicebank.File)); var imagePath = Path.Combine(Location, voicebank.Image); Avatar = LoadAvatar(imagePath); Loaded = true; if (voicebank.PrefixMap != null) { PitchMap = voicebank.PrefixMap.Map; } else { PitchMap = new Dictionary <string, string>(); } OtoSets = new List <UOtoSet>(); foreach (var otoSet in voicebank.OtoSets) { OtoSets.Add(new UOtoSet(otoSet, this, singersPath)); } }