大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> NET专区 -> 在C#下用Microsoft Agent创建超酷语言精灵(附图)

在C#下用Microsoft Agent创建超酷语言精灵(附图)

时间: 2021-07-31 作者:daque

【打字与印刷本子】【引荐给伙伴】 在C#下用Microsoft Agent创建超酷语言精灵(附图)c#动作microsoft .net策略下的新兴谈话,有其不行比较的宏大功效。动作一种rad谈话,它有visual basic赶快开拓运用步调的便宜,又不乏c++谈话的面相东西的崇高个性。 正文就经过引见运用microsoft agent来创造一个超酷用户界面(就像office2000那种办公室帮忙的界面,并有语音朗诵功效)来向大师展现一下用c#举行windows运用步调赶快开拓的便宜。 一 概括 微软的office2000顶用到了少许被称为“办公室帮忙”(office assistance)的精灵来给用户供给扶助,如许做的功效是不言而喻的,大师不妨获得很灵验的扶助而且运用户界面显得特殊和睦。此刻,咱们只有运用microsoft agent(鉴于com),咱们就不妨在本人的步调中运用这种精灵来给步调出色添彩。用这种精灵,咱们不妨实行语音的朗诵、扮演动画以至还不妨实行语音辨别呢! 二 诉求 (1)微软公司视窗2000效劳器版或视窗 xp 版 (2).net framewrok sdk beta 2版 (3)microsoft agent中心组装 (4)microsoft agent的精灵:吉尼(genie)、么林(merlin)、罗比(robby)和皮蒂(peedy) (5)至罕见一个英语的text-to-speech引擎(此刻还找不到华文的) (6)微软运转时发音api4.0a (即使还要实行语音辨别功效的话,还要有微软的语音辨别引擎) 一切那些都不妨在http://microsoft.com/msagent/downloads.htm载入。其余,必需要安置office2000(office97是不行的)。 三 实行本领 1.翻开vs.net,兴建一个工程,无妨取名为coolui。图示如次: 2.创造用户界面。 采用菜单:东西->自设置东西箱,并采用microsoft agent control 2.0组件,图示将microsoft agent control控件增添到窗体上(在步调运转时是看得见窗体是的microsoft agent控件的,惟有在安排界面时它才表露出来),并课安排窗体如次: 将主窗体的text属性树立为“coolui”;将左边三个按钮的text属性辨别树立为“导出精灵”、“朗诵文本”、“湮没精灵”;将textbox的text属性树立为“type anything here for the character to read for you!(only english)”,multiline属性树立为true。 3.大略的用户界面仍旧实行,此刻咱们来举行代码局部的处事: 开始,增添using agentobjects;到代码的发端处。其次,在咱们的类里增添独占数据分子:private iagentctlcharacterex character;(这即是咱们要用到的精灵的东西)。窜改结构因变量如次: public form1() { // // required for windows form designer support // initializecomponent(); button2.enabled=false;//先使底下的两个按钮失效 button3.enabled=false; // // todo: add any constructor code after initializecomponent call // } 接着,增添左边三个按钮的鼠标单击的动静相映因变量: private void button1_click(object sender, system.eventargs e) private void button2_click(object sender, system.eventargs e) private void button3_click(object sender, system.eventargs e) 代码如次: private void button1_click(object sender, system.eventargs e) { axagent1.characters.load("genie", (object)"genie.acs");//导出吉尼这个精灵 character = axagent1.characters["genie"]; character.languageid = 0x409;//把谈话树立为英语,这边不许是华文 character.show(null);//表露精灵 button1.enabled=false;//从新树立按钮的灵验性 button2.enabled=true; button3.enabled=true; } private void button2_click(object sender, system.eventargs e) { if(textbox1.text.length == 0) //即使没有字符的话,就不读 return; character.speak(textbox1.text, null);//让精灵朗诵文本 } private void button3_click(object sender, system.eventargs e) { character.play("wave"); character.play("hide");//湮没精灵 } 一切完备的代码如次: using system; using system.drawing; using system.collections; using system.componentmodel; using system.windows.forms; using system.data; using agentobjects; namespace coolui { /// <summary> /// summary description for form1. /// </summary> public class form1 : system.windows.forms.form { private axagentobjects.axagent axagent1; private iagentctlcharacterex character; private system.windows.forms.textbox textbox1; private system.windows.forms.button button1; private system.windows.forms.button button2; private system.windows.forms.button button3; /// <summary> /// required designer variable. /// </summary> private system.componentmodel.container components = null; public form1() { // // required for windows form designer support // initializecomponent(); button2.enabled=false;//先使底下的两个按钮失效 button3.enabled=false; // // todo: add any constructor code after initializecomponent call // } /// <summary> /// clean up any resources being used. /// </summary> protected override void dispose( bool disposing ) { if( disposing ) { if (components != null) { components.dispose(); } } base.dispose( disposing ); } #region windows form designer generated code /// <summary> /// required method for designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void initializecomponent() { system.resources.resourcemanager resources = new system.resources.resourcemanager(typeof(form1)); this.textbox1 = new system.windows.forms.textbox(); this.button1 = new system.windows.forms.button(); this.button2 = new system.windows.forms.button(); this.button3 = new system.windows.forms.button(); this.axagent1 = new axagentobjects.axagent(); ((system.componentmodel.isupportinitialize)(this.axagent1)).begininit(); this.suspendlayout(); // // textbox1 // this.textbox1.location = new system.drawing.point(112, 24); this.textbox1.multiline = true; this.textbox1.name = "textbox1"; this.textbox1.size = new system.drawing.size(224, 152); this.textbox1.tabindex = 2; this.textbox1.text = "type anything here for the character to read for you!(only english)"; // // button1 // this.button1.location = new system.drawing.point(16, 24); this.button1.name = "button1"; this.button1.tabindex = 1; this.button1.text = "导出精灵"; this.button1.click += new system.eventhandler(this.button1_click); // // button2 // this.button2.location = new system.drawing.point(16, 80); this.button2.name = "button2"; this.button2.tabindex = 1; this.button2.text = "朗诵文本"; this.button2.click += new system.eventhandler(this.button2_click); // // button3 // this.button3.location = new system.drawing.point(16, 136); this.button3.name = "button3"; this.button3.tabindex = 1; this.button3.text = "湮没精灵"; this.button3.click += new system.eventhandler(this.button3_click); // // axagent1 // this.axagent1.enabled = true; this.axagent1.location = new system.drawing.point(320, 176); this.axagent1.name = "axagent1"; this.axagent1.ocxstate = ((system.windows.forms.axhost.state)(resources.getobject("axagent1.ocxstate"))); this.axagent1.size = new system.drawing.size(32, 32); this.axagent1.tabindex = 0; // // form1 // this.autoscalebasesize = new system.drawing.size(6, 14); this.clientsize = new system.drawing.size(360, 213); this.controls.addrange(new system.windows.forms.control[] { this.button3, this.button2, this.textbox1, this.button1, this.axagent1}); this.name = "form1"; this.text = "coolui"; ((system.componentmodel.isupportinitialize)(this.axagent1)).endinit(); this.resumelayout(false); } #endregion /// <summary> /// the main entry point for the application. /// </summary> [stathread] static void main() { application.run(new form1()); } private void button1_click(object sender, system.eventargs e) { axagent1.characters.load("genie", (object)"genie.acs");//导出吉尼这个精灵 character = axagent1.characters["genie"]; character.languageid = 0x409;//把谈话树立为英语,这边不许是华文 character.show(null);//表露精灵 button1.enabled=false;//从新树立按钮的灵验性 button2.enabled=true; button3.enabled=true; } private void button2_click(object sender, system.eventargs e) { if(textbox1.text.length == 0) //即使没有字符的话,就不读 return; character.speak(textbox1.text, null);//让精灵朗诵文本 } private void button3_click(object sender, system.eventargs e) { character.play("wave"); character.play("hide");//湮没精灵 } } } 4.好了,此刻实行了一切的处事了,安ctrl+f5试试功效吧!

在c#下用microsoft agent创建超酷语言精灵(附图)图1

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.