微软AGENT简介

   微软Agent API能够提供卡通角色的显示,另外,它还可以支持语音识别,因此应用软件可以对语音命令作出反应,而卡通角色可以通过合成的语音、录制好的音频信号或文字对命令作出反应。
   使用微软AGENT的要求

   要使用该技术,我们必须有下面的组件:

   ·微软Agent核心组件

   ·微软Agent中的卡通角色━━Genie、Merlin、Robby和Peedy

   ·微软Speech API 4.0a运行时间库

   ·微软语音识别引擎

   ·Lernout和Hauspie文字-语音引擎 
 

语音技术简介

   文字-语音转换指的是计算机将文字信息转换为合成语音进行输出,语音识别是指计算机能够识别出说话者所说的话,接受说话者的命令和输入的数据。

   语音识别和文字-语音转换都需要用到相关的引擎,几乎所有的语音识别引擎都是将输入的语音数据转换为与特定引擎相关的音素,然后这些音素被转换为应用程序能够使用的文字。

   文本-语音转换的二种方式:

   1、合成文本-语音转换

   2、连续文本-语音转换

合成文本-语音转换方式:

   在合成的发音方式中,引擎处理每个单词,并产生该单词的发音音素,然后这些音素被转入一个复杂的算法中,模仿人类的发声方式,生成语音。

连续文本-语音转换方式:

   在连续文本-语音转换方式中,引擎对文本信息进行处理,从一个预先录制好的语音库中找出句子、单词和短语,在这种方式中,生成的语音是连续的。
语音应用程序的编程接口

   微软语音应用程序编程接口在Win32(Windows 95、Windows NT)下使用了OLE组件对象模式(COM)架构,微软的Agent架构在合成语音输出中使用了微软语音应用程序编程接口(SAPI),还使用SAPI支持语音输入(语音识别SR或文本-语音转换TTS)。微软的Agent定义了让应用程序访问其服务的接口,使得应用程序能够控制角色动画、支持用户输入事件,指定输出方式。

 角色窗口

   在微软Agent应用程序中,卡通角色是在它们各自的窗口中被显示的,这些窗口总是出现在Z轴顺序的最顶端。用户可以通过鼠标左键拖动角色移动角色所在的窗口,角色的图像随着指针而移动。

说话汽球圈

   除了语音输出外,动画角色还支持以卡通类型说话汽球圈形式的文字字幕,角色说话时,所说的文字就出现在汽球圈儿中,当说完时,汽球圈也就不见了。
 

在.NET架构中使用微软AGENT

   微软Agent不是以ActiveX控制DLL的形式提供的。要在.NET中使用它,可以使用由.NET框架SDK提供的AxImp.exe工具:

   AxImp --&gt> ActiveX控制-Win窗体组合体生成器 

   Syntax: AxImp [/? | [[/source] OCXName]]

   Aximp agentctl.dll

   上面的命令生成二个文件:AxAgentObjects.dll和AgentObjects.dll。通过使用这二个文件,我们就可以在.NET中使用Agent了。
       添加axagent控件,可以“工具箱”-“选择项”-“COM组件”-“Microsoft Agent Control 2.0”

       如下附代码:(不添加axagent控件的版本)

        public   AgentObjects.Agent MyController ;
        public   AgentObjects.IAgentCtlCharacter MyCharacter ;

         //初始化精灵对象
        private void Form1_Load(object sender, EventArgs e)
        {
         MyController=new AgentObjects.AgentClass();
         MyController.Connected=true;
         MyController.Characters.Load("Merlin",(object)"Merlin.acs");
         MyCharacter = MyController.Characters.Character("merlin");
         //MyCharacter = axAgent1.Characters["Merlin"];
         MyCharacter.MoveTo(System.Convert.ToInt16(Location.X + 300), System.Convert.ToInt16(Location.Y + 80), null);                    
        }

        //演示说话效果
        private void btnSpeak_Click(object sender, EventArgs e)
        {
            if (this.txtSpeak.Text == string.Empty)
            {
                MessageBox.Show("请输入说话内容!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            MyCharacter.Speak(this.txtSpeak.Text, null);
        }

         //演示一个实例:祝贺
        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (this.radioButton1.Checked)
            {
                this.MyCharacter.StopAll(null);
                this.MyCharacter.Play("Congratulate");
            }
        }

 

       添加一些merlin的动作:    

action[0]=" Acknowledge "; //承认
action[1]=" LookDown "; //向下看
action[2]=" Sad "; //悲伤
action[3]=" Alert "; //警告
action[4]=" LookDownBlink "; //向下看眨眼
action[5]=" Search "; //寻找
action[6]=" Announce "; //声明
action[7]=" LookUp "; //向上看
action[8]=" StartListening "; //开始聆听
action[9]=" Blink "; //眨眼
action[10]=" LookUpBlink "; //向下看眨眼
action[11]=" StopListening "; //停止聆听
action[12]=" Confused "; //迷惑
action[13]=" LookLeft "; //向左看
action[14]=" Suggest "; //建议
action[15]=" Congratulate "; //祝贺
action[16]=" LookLeftBlink "; //向左看眨眼
action[17]=" Surprised "; //吃惊
action[18]=" Declines "; //拒绝
action[19]=" LookRight "; //向右看
action[20]=" Think "; //思考
action[21]=" DontRecognize "; //不承认
action[22]=" LookRightBlink "; //向右看眨眼
action[23]=" Wave "; //挥动
action[24]=" Explain "; //解释
action[25]=" MoveDown "; //向下移动
action[26]=" Write "; //书写
action[27]=" GestureDown "; //向下姿势
action[28]=" MoveUp "; //向上移动
action[29]=" Processing "; //计算
action[30]=" GestureUp "; //向上姿势
action[31]=" MoveRight "; //向右移动
action[32]=" Reading "; //阅读
action[33]=" GestureLeft "; //向左姿势
action[34]=" MoveLeft "; //向左移动
action[35]=" Searching "; //寻找
action[36]=" GestureRight "; //向右姿势
action[37]=" Pleased "; //高兴
action[38]=" Writing "; //书写
action[39]=" GetAttention "; //获得注意
action[40]=" Read "; //阅读
action[41]=" Greet "; //问候