public void SetLyric(List <Word> words, bool skipRest = true) { int? n = Notes[0].Number == NumberManager.PREV ? 1 : 0; // нота int s = 0; // слог int w = 0; // слово string cc = ""; while (w < words.Count && n < Notes.Length) { n = SkipNotes(n.Value); if (!n.HasValue) { break; } /// Прелоги типа к, с, ф if (words[w].Phonemes.All(p => !Atlas.IsVowel(p))) { var new_cc = string.Join(" ", words[w].Phonemes); cc = cc.Length > 0? string.Join(" ", cc, new_cc) : new_cc; w++; continue; } if (cc.Length > 0) { Notes[n.Value].SetParsedLyric(Atlas, $"{cc} {words[w].Syllables[s]}"); } else { Notes[n.Value].SetParsedLyric(Atlas, words[w].Syllables[s].ToString()); } Notes[n.Value].Syllable = words[w].Syllables[s]; if (s == 0) { Notes[n.Value].Word = words[w]; } n++; if (words[w].Phonemes.Any(p => Atlas.IsVowel(p))) { cc = ""; } s++; if (s == words[w].Syllables.Count) { s = 0; w++; } } if (w < words.Count - 1) { Errors.WarningBox("Недостаточно нот для введенного текста. Часть текста была утеряна.", "Предупреждение"); } foreach (var note in Notes) { note.SetParsedLyric(Atlas, Atlas.PhonemeReplace(note.ParsedLyric)); } }
public Syllable(IEnumerable <string> phonemes, Atlas atlas) { Phonemes = phonemes.ToArray(); try { List <string> phs = phonemes.ToList(); if (Phonemes.Any(n => atlas.IsVowel(n))) { ContainsVowel = true; int v = phs.FindIndex(n => atlas.IsVowel(n)); VowelIndex = v; Vowel = phs[v]; int count = phs.Count; if (v > 0) { CV = phs.GetRange(v - 1, 2).ToArray(); Beginning = phs.GetRange(0, v + 1).ToArray(); ConsonantBeginning = phs.GetRange(0, v).ToArray(); } else { CV = new[] { Vowel }; Beginning = new[] { Vowel }; } if (v > 2) { ExtraConsonantBeginning = phs.GetRange(0, v - 1).ToArray(); } if (v < count - 1) { VC = phs.GetRange(v, 2).ToArray(); Ending = phs.GetRange(v, count - v).ToArray(); ConsonantEnding = phs.GetRange(v + 1, count - v - 1).ToArray(); } else { Ending = new string[] { Vowel } }; if (v < count - 2) { ExtraConsonantEnding = phs.GetRange(v + 2, count - v - 2).ToArray(); } } } catch (Exception ex) { Errors.ErrorMessage(ex, "Error on Syllable parsing"); } }
public string[] MergeCV(string[] phonemes) { List <string> phs = phonemes.ToList(); for (int i = 1; i < phs.Count; i++) { if (_isMergeCV && Atlas.IsConsonant(phs[i - 1]) && Atlas.IsVowel(phs[i])) { //phs[i - 1] = Atlas.GetAlias("CV", new[] { phs[i - 1], phs[i] }); // Слишком долго блет phs[i - 1] = String.Join("", phs[i - 1], phs[i]); phs.RemoveAt(i); i--; } } return(phs.ToArray()); }