//int getPythonOutputInterval = 0.5; private void ViewCommands() { textBoxCommands.IsEnabled = false; // Prevent changes before textBox is loaded. tabItemCommands.IsEnabled = true; tabItemCommands.Visibility = Visibility.Visible; gridCommands.Visibility = Visibility.Visible; gridCommands.IsEnabled = true; tabItemCommands.Focus(); textBoxCommands.Focus(); textBoxCommands.HorizontalScrollBarVisibility = 0; textBoxCommands.Text = ""; //textBoxCommands.AcceptsReturn = true; //commandsText = GetExampleText(); commandsText = commandsHeader + commandPrompt; textBoxCommands.AppendText(commandsText); commandsText = textBoxCommands.Text; textBoxCommands.CaretIndex = textBoxCommands.Text.Length; promptIndex = textBoxCommands.CaretIndex; lastCaretIndex = textBoxCommands.CaretIndex; // Image Control BitmapImage imageSource = new BitmapImage(new Uri( @"C:\Users\User2\Dev\AI Dev\AIDev Resources\Images\readingcouch660x357.jpg", UriKind.RelativeOrAbsolute)); imageInputImage1.Source = imageSource; //C:\Users\User2\Dev\AI Dev\AIDev Resources\Images\readingcouch660x357.jpg //C:\Users\User2\Dev\AI Dev\AIDev Resources\Images\Psychedelic Explosion.jpg // Place in first tab position. tabWorkspace.Items.Remove(tabItemCommands); tabWorkspace.Items.Insert(0, tabItemCommands); LangBnf.LoadLexRules(); LoadUDWords(); string loadSynthResult = ""; if (startWithRecAndSynthOn) { loadSynthResult = Speech.LoadSpeechSynthesizer(); if (loadSynthResult == "") { checkBoxVoiceSynth.IsChecked = true; } string loadRecResult = Speech.LoadSpeechRecognizer(); if (loadRecResult == "") { checkBoxVoiceRecogition.IsChecked = true; } } else { if (checkBoxVoiceSynth.IsChecked == true) { loadSynthResult = Speech.LoadSpeechSynthesizer(); } if (checkBoxVoiceRecogition.IsChecked == true) { Speech.LoadSpeechRecognizer(); } } if (loadSynthResult != "") { checkBoxVoiceSynth.IsChecked = false; } textBoxCommands.IsEnabled = true; tabItemCommands.Focus(); }
public void ProcessStatements(string statements) { statements = statements.Trim(); if (statements.StartsWith("speak")) { statements = statements.Substring(6, statements.Length - 6); Speech.Speak(Speech.AddPronunciation(statements)); textBoxCommands.CaretIndex = textBoxCommands.Text.Length; textBoxCommands.AppendText("\r\n\r\n" + commandPrompt); commandsText = textBoxCommands.Text; promptIndex = textBoxCommands.Text.Length; textBoxCommands.CaretIndex = textBoxCommands.Text.Length; lastCaretIndex = textBoxCommands.Text.Length; } else if (statements.StartsWith("getvoices")) { string installedVoices = Speech.GetInstalledVoices(); textBoxCommands.CaretIndex = textBoxCommands.Text.Length; textBoxCommands.AppendText("\r\n\r\n" + installedVoices + "\r\n" + commandPrompt); commandsText = textBoxCommands.Text; promptIndex = textBoxCommands.Text.Length; textBoxCommands.CaretIndex = textBoxCommands.Text.Length; lastCaretIndex = textBoxCommands.Text.Length; } else if (statements.ToLower() == "python") { string response = TcpConnection.SendMessage("python"); commandPrompt = pythonCommandPrompt; textBoxCommands.CaretIndex = textBoxCommands.Text.Length; textBoxCommands.AppendText("\r\n" + response.TrimEnd() + "\r\n\r\n" + commandPrompt); commandsText = textBoxCommands.Text; promptIndex = textBoxCommands.Text.Length; textBoxCommands.CaretIndex = textBoxCommands.Text.Length; lastCaretIndex = textBoxCommands.Text.Length; } else if (commandPrompt == pythonCommandPrompt) { string response = TcpConnection.SendMessage("[py]" + statements); if (response == "[python closed]") { commandPrompt = ">"; // Switch back to normal command prompt. StopOutput(); } else { lastPythonOutputTime = DateTime.UtcNow; timerPythonOutput = new DispatcherTimer(); timerPythonOutput.Tick += new EventHandler(TimerPythonOutput_Tick); timerPythonOutput.Interval = new TimeSpan(0, 0, 0, 0, 200); timerPythonOutput.Start(); } } else { string response = TcpConnection.SendMessage("processstatements " + statements); if (response == "RefreshUDWords") { // Maybe split pronunciations out of AddRecRulesFromLexRules, since they are // for spokenSynth and can be added separately just for voice synth. LangBnf.LoadLexRules(); LoadUDWords(); if (checkBoxVoiceRecogition.IsChecked == true) { Speech.LoadSpeechRecognizer(); } if (checkBoxVoiceSynth.IsChecked == true) { Speech.AddSynthRulesFromLexRules(); } response = "okay;"; } textBoxCommands.CaretIndex = textBoxCommands.Text.Length; textBoxCommands.AppendText("\r\n" + response.TrimEnd() + "\r\n\r\n" + commandPrompt); commandsText = textBoxCommands.Text; promptIndex = textBoxCommands.Text.Length; textBoxCommands.CaretIndex = textBoxCommands.Text.Length; lastCaretIndex = textBoxCommands.Text.Length; if (Speech.Synth != null && checkBoxVoiceSynth.IsChecked == true && response.Length < 200) { Speech.Speak(response); } } }