转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
Microsoft Agent Tutorial Chapter 2         ★★★★

Microsoft Agent Tutorial Chapter 2

作者:闵涛 文章来源:闵涛的学习笔记 点击数:755 更新时间:2009/4/23 16:39:21
Microsoft Agent Tutorial Chapter 2

Author: Abstractvb
Date: 4/22/2000 6:54:54 PM
ID: 84
Microsoft Agent Version 2 Needed.

Shows how to recieve input from the user via speech.  This uses the Text to Speech engine and MSAgents commands to determine what the user said and take action. This covers commands, and confidence settings.

 

Part 1 - Adding Agent Commands

To get the Agent to respond to userinput you will need to add commands.  Commands are a word or series of words the Agent waits for. Once one of the commands is spoken the agent will call the Commands() Event and return the name of the command that was spoken.

Name your Agent Control MSAgent.

Add this to the Form_Load() Event:

MSAgent.Characters.Load "DefaultCharacter" 
Set AgentChar= MsAgent.Characters("DefaultCharacter")
AgentChar.Commands.Add "Notepad", "Notepad", "Notepad", True, True
	
Private Sub MsAgent_Command(ByVal UserInput As Object)
    MsgBox UserInput.Name
End Sub

There, now try running it. Press SCROLLLOCK and then say your agents name to get him to appear. Once the agent has appeared press SCROLLLOCK again to get the agent to listen and then say the word "Notepad". A msgbox should appear with the word notepad in it, since that is the name we gave our command.

The first parameter listed above is the name that is what the Command() Event will return to you when your command is spoken. The next is the Caption parameter, which will determine how this command is displayed in the Agent Voice Commands Window. The third is the Voice property. The voice property is what the user must say to evoke this command. The voice property does not have to be the same as the Name or the Caption.

Now take a look at this line of code:

AgentChar.Commands.Add "notepad", "notepad", "[...] notepad [...]", True, True

Notice the ellipses in brackets? These have a special meaning to the Text to speech engine. These basically mean to ignore any speech before and after the word notepad. So you could say something like this "Open notepad please" and it will still return the "Notepad" command.  Be careful when using the ellipses though, since they slow down processing considerably.

 

Part 2 - It''''s all Guesswork!

When a command is spoken the Agent takes its best guess and then returns you a command. The command may not always be correct, since the Agent is really just making a guess. Imagine this scenario: You have the agent setup to delete a database entry when the user speaks a specific command. Now you would want to ensure that MSAgent is fairly confident in the command before you wipe out valuable data. Thankfully MSAgent has a property designed to let you know just how certain the agent is about a command.

The UserInput object has a confidence property designed just for this purpose; the Confidence property. Confidence properties in MSAgent can range from -100 to 100. Try this:

Private Sub MsAgent_Command(ByVal UserInput As Object)
    If UserInput.Confidence > -50 Then
        MsgBox UserInput.Name
    Else
        MsgBox "I have " & UserInput.Confidence & " confidence in that command"
    End If
End Sub

Sometimes you want to have different confidence levels for different commands. There is a property for this as well. Each command object can have a confidence level specified and a confidence text specified. If the agents confidence level does not meet or exceed the confidence level you set then the confidence text will be displayed in the agents ToolTip. Try adding this to the Form_Load:

AgentChar.Commands("notepad").Confidence = "50"
AgentChar.Commands("notepad").ConfidenceText = "Was that notepad you wanted?"

Notice that when the agents confidence level is below 50 it will display the ConfidenceText in the tooltip. But you should also notice that the agent will still proceed with the command and show the msgbox. To avoid that you would need to add code to check the UserInput confidence setting and the Command confidence setting to see if the latter is met or exceeded. Something like this:

If UserInput.Confidence > AgentChar.Commands(UserInput.Name).Confidence Then
	MsgBox UserInput.Name
End If

There is also other parameters to let you know what other commands the agent considered when guessing. You can get the name of the second best match using the UserInput.Alt1Name, and the third best match using the UserInput.Alt2Name properties. Each of these have their own confidence scoring (Alt1Confidence, and Alt2Confidence). I guess one use for this would be to query the user showing all three choices and get the user to clarify the choice.

Sometimes the agent will get a built in command like "Show" or "Hide". In this case no Command names are returned. So to determine if any command names are returned the best way is to check the Userinput.Count property. This will tell you if 1, 2 or 3 guesses were returned from the agent. If only two are returned then the Alt2Name property will be empty so there will be no use checking it.


[聊天工具]Microsoft Office 2007简体中文版最新截图  [系统软件]delphi2005帮助系统使用了microsoft document exp…
[VB.NET程序]在VB.NET中应用Agent技术  [VB.NET程序]Microsoft Office,VB.NET编程 PIA使用小程序
[VB.NET程序]VBCOM TUTORIAL(3)  [VB.NET程序]VBCOM TUTORIAL(2)
[VB.NET程序]VBCOM TUTORIAL(1)  [Delphi程序]Borland与Microsoft关于Delphi的对话
[Delphi程序]Borland 公布支持 Microsoft  .NET平台产品策略  [Delphi程序]ms agent 经典用法
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台