private void ButtonOK_Click(object sender, RoutedEventArgs e) { string text = textBox.Text; string phonemes = ModuleSpeakPhonemes2.GetPronunciationFromText(text); labelIn.Text = phonemes; ((ModuleSpeakPhonemes2)ParentModule).FirePhonemes(phonemes); }
private void Button_Click(object sender, RoutedEventArgs e) { string textFileName = "readingsample1.txt"; OpenFileDialog openFileDialog1 = new OpenFileDialog { Filter = "TXT Command Files|*.txt", Title = "Select a Brain Simulator Command File" }; // Show the Dialog. // If the user clicked OK in the dialog DialogResult result = openFileDialog1.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { textFileName = openFileDialog1.FileName; if (File.Exists(textFileName) && textFileName.IndexOf("Phonemes") == -1) { string outFileName = System.IO.Path.GetFileNameWithoutExtension(textFileName); outFileName = textFileName.Replace(outFileName, outFileName + "-Phonemes"); List <string> outFileStrings = new List <string>(); string[] commands = File.ReadAllLines(textFileName); foreach (string s in commands) { if (s == "STOP") { break; } string s1 = s.Replace("\"", ""); s1 = s1.Replace("“", ""); s1 = s1.Replace("”", ""); s1 = s1.Replace("'", ""); s1 = s1.Replace(",", "."); string[] s2 = s1.Split('.'); foreach (string s3 in s2) { string phonemes = ModuleSpeakPhonemes2.GetPronunciationFromText(s3.Trim()); if (phonemes != "") { //((ModuleSpeakPhonemes)ParentModule).FirePhonemes(phonemes); outFileStrings.Add(phonemes); } } } File.WriteAllLines(outFileName, outFileStrings); } if (textFileName.IndexOf("-Phonemes") == -1) { string outFileName = System.IO.Path.GetFileNameWithoutExtension(textFileName); textFileName = textFileName.Replace(outFileName, outFileName + "-Phonemes"); } if (File.Exists(textFileName)) { string[] commands = File.ReadAllLines(textFileName); //note, this is a reverse sort, for rebular, swap x and y if (textFileName.ToLower().IndexOf("vocab") != -1) { Array.Sort(commands, (x, y) => y.Length.CompareTo(x.Length)); } foreach (string phonemes in commands) { ((ModuleSpeakPhonemes2)ParentModule).FirePhonemes(phonemes); } } } }