public void OverrideValues(params string[] values) { Sanity.Requires(values.Length == VALUE_COUNT, $"{VALUE_COUNT} items are required."); SavingItems = values; CurrentTextFile = values[0]; CurrentAudioFolder = values[1]; }
private void GetValues(IEnumerable <string> list) { SavingItems = list.ToArray(); Sanity.Requires(SavingItems.Length >= VALUE_COUNT, BROKEN_MESSAGE); CurrentTextFile = SavingItems[0]; CurrentAudioFolder = SavingItems[1]; }
public void SaveCurrentData(string accent, string highGerman, string context, string lexicon) { Sanity.Requires(DataArray.Length > 0, "The data file is empty!"); var line = new DataLine { WavPath = CleanupData(CurrentLine.WavPath), Accent = CleanupData(accent), HighGerman = CleanupData(highGerman), Context = CleanupData(context), Lexicon = ValidLexicon(lexicon) }; DataArray[CurrentIndex] = line; }
private IEnumerable <string> BytesToValue(byte[] bytes, int index) { if (index < bytes.Length) { Sanity.Requires(index + 4 <= bytes.Length, BROKEN_MESSAGE); int i = BitConverter.ToInt32(bytes, index); Sanity.Requires(index + 4 + i <= bytes.Length, BROKEN_MESSAGE); string value = Encoding.UTF8.GetString(bytes, index + 4, i); yield return(value); foreach (string s in BytesToValue(bytes, index + 4 + i)) { yield return(s); } } }
public void Play() { string wavPath = Path.Combine(InputAudioFolderPath, CurrentLine.WavPath); Sanity.Requires(File.Exists(wavPath), $"Missing file {wavPath}"); using (FileStream fs = new FileStream(wavPath, FileMode.Open, FileAccess.Read)) { try { Player.Stream = fs; Player.Play(); } catch { MessageBox.Show("File error."); } } }
public string ValidLexicon(string i) { StringBuilder tokenSb = new StringBuilder(); StringBuilder sentSb = new StringBuilder(); bool isPrimStress = false; foreach (char c in i) { if (char.IsWhiteSpace(c)) { if (tokenSb.Length > 0) { string token = tokenSb.ToString(); Sanity.Requires(ValidToken(token), $"Invalid phone <{token}>, in work item [{CurrentExternalIndex}]."); if (sentSb.Length > 0 && !isPrimStress) { sentSb.Append(' '); } sentSb.Append(token); isPrimStress = token == "\""; tokenSb.Clear(); } continue; } tokenSb.Append(c); } if (tokenSb.Length > 0) { string last = tokenSb.ToString(); Sanity.Requires(ValidToken(last), $"Invalid phone <{last}>, in work item [{CurrentExternalIndex}]."); if (sentSb.Length > 0 && !isPrimStress) { sentSb.Append(' '); } sentSb.Append(last); } return(sentSb.ToString()); }