private void Speak() { string text = string.Empty; Journal.EventsRow er = j.Events.FindByID(selectedEventID); if (er == null) { return; } if (!er.IsSubjectNull()) { text = er.Subject.ToLower() + " ..."; } if (!er.IsBodyNull()) { text += er.Body.ToLower(); } text = Regex.Replace(text, @"<\s*?lj\s*?user\s*?=\s*?\""?(\w*?)\""?\s*?>", "$1"); text = Regex.Replace(text, "<.+?>", " "); text = text.Replace("\"", "'").Replace(" ", " "); if (!chkShowBalloon.Checked) { text = string.Format("\\map=\"{0}\"=\"\"\\", text); } agent.Stop(null); request = agent.Speak(text, null); if (animations.Count > 0) { agent.Play((string)animations[(new Random()).Next(animations.Count)]); } }
private void doChatting() { idleControl.Stop(); string output = ""; presentLine++; string cleanInputText = inputBox.Text.Trim('\n'); output = pi.chatWithPrelude(cleanInputText); outputBox.AppendText("You: \t" + cleanInputText); GoToLineAndColumn(outputBox, presentLine, 0); outputBox.SelectionColor = Color.Orange; outputBox.AppendText("\n"); presentLine++; if (Character != null && lastAgent != "") { outputBox.AppendText(Character.Name + ": \t" + output); } else { outputBox.AppendText("CPU: \t" + output); } GoToLineAndColumn(outputBox, presentLine, 0); outputBox.SelectionColor = Color.Blue; outputBox.AppendText("\n"); outputBox.Focus(); inputBox.Text = ""; inputBox.Focus(); try { if (this.Character != null && enabledAgent == true) { charReq = this.Character.Speak(output, null); } } catch (System.Exception e) { MessageBox.Show("Error occured: " + e.ToString()); } idleControl.Start(); }
private void cmbCharacter_SelectedIndexChanged(object sender, System.EventArgs e) { if (loaded) { agentHost.Characters.Unload("Character"); } settings.SelectedCharacter = (string)cmbCharacter.SelectedItem; agentHost.Characters.Load("Character", settings.SelectedCharacter + ".acs"); agent = agentHost.Characters["Character"]; agent.Commands.Add("Show Options", "Show Options", "Show Options", true, true); agent.Show(null); agent.MoveTo((short)settings.Location.X, (short)settings.Location.Y, null); animations = new ArrayList(); foreach (string name in agent.AnimationNames) { if (name.ToLower() != "hide") { animations.Add(name); } } if (!loaded) { if (agent.TTSModeID == null || agent.TTSModeID == string.Empty) { request = agent.Speak("Hello! " + "To hear my voice, you must have the proper speech drivers installed on your system. " + "Please visit the ljArchive web site to read how to set them up.", null); } else { request = agent.Speak("Hello! " + "I can read your journal entries to you. " + "Left click on me to have me start or stop reading the current entry. " + "For more options, right click on me and select Show Options.", null); } loaded = true; } }