Microsoft Agent Tutorial Chapter 2

原创 2004年09月10日 23:10:00
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
        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.


原文出处: 文|章小飞(Aaron Zhang) 谷歌 Angular 技术推广工程师 背景介绍:Angular...
  • chelen_jak
  • chelen_jak
  • 2016年12月19日 17:00
  • 563


作者:刘威威编辑:李文臣11.GAN的 ‘前世’?大家都知道GAN是Ian Goodfellow 2 014年放出的一篇开山之作,在深度学习界评价很高,可以说GAN的出现,给深度学习界带来了很多的研究...
  • u013709270
  • u013709270
  • 2017年12月09日 00:00
  • 752

PyQt4 tutorial读书笔记(2)

Statusbar、Menus and toolbars in PyQt4英文参考: 把三者整合到一起的代...
  • oZuiJiaoWeiYang
  • oZuiJiaoWeiYang
  • 2015年03月04日 16:17
  • 640

graph slam tutorial :从推导到应用2

在上一部分中通过一个例子大致了解了graph based slam的优化过程。在本篇博客中将提升一个层次,对图优化的求解过程进行推导。由于博文关注的在图构建好以后,如何调整机器人位姿使误差最下。因此,...
  • heyijia0327
  • heyijia0327
  • 2015年10月12日 11:04
  • 9217

chapter 2 指针与引用

一、有符号数与无符号数 有符号数和无符号数运算自动变成无符号数 二、指针与引用 1,某个值的引用无法改变,即是说引用只能引用一个对象 &*p 错误,因为引用不是对象;int *&p正确 ...
  • ZZZz12zzZZ
  • ZZZz12zzZZ
  • 2016年09月17日 21:31
  • 88


Ubuntu14.04中Docker的基本使用 1、安装 1.1 使用apt-get安装(非最新版本) sudo apt-get install 1.2 下载安装(...
  • wang_san_shi
  • wang_san_shi
  • 2015年08月26日 15:49
  • 1345

【Java Tutorial】: Getting Started(开始入门)【官方原版教程】

入门: 这个页面内容提供了你需要了解并开始使用Java编程语言的一切。
  • RuingMan
  • RuingMan
  • 2016年02月05日 17:58
  • 1557

Unity实例.003官方示例Survival Shooter Tutorial核心代码学习

Unity官方教学实例《噩梦射手》(Survival Shooter Tutorial)的一些核心代码的学习,包括如何实现角色的移动,摄像机的跟随,敌人的寻路,玩家的生命控制等等内容。...
  • Constant23
  • Constant23
  • 2017年05月02日 16:15
  • 954

什么是 agent

agent 是任何通过sensor感知其环境并通过actuators在此环境中作出行动的东西。 比如人agent:sensor 是眼睛,耳朵,以及其他器官,actuators 是手,腿,声道等。 ...
  • cuit
  • cuit
  • 2017年02月28日 17:23
  • 291

Spring Cloud(二)Consul 服务治理实现

Spring Cloud Consul 项目是针对Consul的服务治理实现。Consul是一个分布式高可用的系统,具有分布式、高可用、高扩展性。Consul 简介Consul 是 HashiCorp...
  • u012889902
  • u012889902
  • 2017年12月01日 18:20
  • 109
您举报文章:Microsoft Agent Tutorial Chapter 2