/// <summary> /// Ask agent to speak /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSpeak_Click(object sender, System.EventArgs e) { AgentServer Srv = new AgentServer(); if (Srv == null) { MessageBox.Show("ERROR: Agent Server couldn't be started!"); } IAgentEx SrvEx; // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object SrvEx = (IAgentEx)Srv; // First try to load the default character int dwCharID = 0, dwReqID = 0; try { // null is used where VT_EMPTY variant is expected by the COM object String strAgentCharacterFile = null; if (!strFileName.Equals(string.Empty)) { //Get the acs path strAgentCharacterFile = strPath + strFileName; } else { MessageBox.Show("Select Style"); return; } if (TxtSpeakInput.Text.Equals(string.Empty)) { TxtSpeakInput.Text = "Please enter text in textbox"; } SrvEx.Load(strAgentCharacterFile, out dwCharID, out dwReqID); } catch (Exception) { MessageBox.Show("Failed to load Agent character! Exception details:"); } SrvEx.GetCharacterEx(dwCharID, out CharacterEx); //CharacterEx.SetLanguageID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); // Show the character. The first parameter tells Microsoft // Agent to show the character by playing an animation. // Make the character speak // Second parameter will be transferred to the COM object as NULL CharacterEx.Speak(TxtSpeakInput.Text, null, out dwReqID); }
public void Say(String str) { int nReqID; m_CharacterEx.Speak(str, null, out nReqID); }
private void MainDict_Load(object sender, EventArgs e) { //kiểm tra khởi động cùng windows if (rkApp.GetValue("iDict") == null) { cmsStartWithWindows.Checked = false; } else { cmsStartWithWindows.Checked = true; } //load từ điển và các thiết lập path = Application.StartupPath; // //strFileName = path + "\\resources\\msagent\\genie.acs"; strFileName = path + "\\resources\\msagent\\vrgirl.acs"; //strFileName = "\\" + CBSelectStyle.SelectedItem.ToString() + ".acs"; // Hien thi agent ShowAgent(); // Doc loi chao mung. CharacterEx.Speak("Hi, I'm a virtual girl, also your assistant. Thanks for using iDict, a multi language, multi function and very smart dictionary. Nice day!", null, out dwReqID); string[] tmpArray = File.ReadAllLines(path + "\\stored.dat"); establish = tmpArray[0]; listDict = new string[tmpArray.Length - 1]; for (i = 1; i < tmpArray.Length; i++) { listDict[i - 1] = tmpArray[i]; } if (listDict.Length > 0) { Dicts = new Dict[listDict.Length]; bool notFoundDict = false; for (i = 0; i < Dicts.Length; i++) { if (File.Exists(path + "\\Dictionary\\" + listDict[i] + ".idt")) { Dicts[i] = new Dict(path + "\\Dictionary\\" + listDict[i] + ".idt"); tabDictList.TabPages.Add(Dicts[i].dln[3]); } else { notFoundDict = true; Dicts[i] = null; } } //nếu không thấy từ điển thì ghi lại file stored.dat if (notFoundDict == true) { StreamWriter stw = File.CreateText(path + "\\stored.dat"); stw.Write(establish); for (i = 0; i < Dicts.Length; i++) { if (Dicts[i] != null) { stw.Write("\r\n" + Dicts[i].fileName); } } stw.Flush(); stw.Close(); Application.Restart(); return; } //load item vào combobox if (File.Exists(path + "\\Items.txt")) { StreamReader str = new StreamReader(path + "\\Items.txt"); int i = 0; while ((tmp = str.ReadLine()) != null && i < 50) { cbbWord.Items[i] = tmp; i++; } str.Close(); } //bắt đầu thiết lập thuộc tính cho từ điển cbbKeypad.SelectedIndex = int.Parse(establish[0].ToString()); } else { DialogResult result = MessageBox.Show("There's no database in the dictionary. Do you want to create or use the one?", "Announcement", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { ManageDict frm = new ManageDict(cbbKeypad.SelectedIndex); frm.ShowDialog(); } else { MessageBox.Show("The application can't run without at least a database.", "Announcement"); } Application.Exit(); return; } // Lay giong phat am foreach (ISpeechObjectToken t in voice.GetVoices("", "")) { cbbVoice.Items.Add(t.GetAttribute("Name")); } miniDict = new MiniDict(Dicts.Length); similarWord = new string[15 * tabDictList.TabCount]; listLength = (lstWordsList.Height - 4) / lstWordsList.ItemHeight; listDict = new string[listLength]; for (i = 0; i < listDict.Length; i++) { lstWordsList.Items.Add(""); } OpenDict(); }