MSAgent: An Introduction

 

MSAgent has been around for a few years now, but I never really paid any attention to the technology. But a few weeks ago I came a cross the Microsoft Agent site and started checking it out. So I loaded VB and started playing round with the characters, not only was it easy to manipulate the characters but I was actually having fun. So I decided to write a tutorial on how to use MSAgent, I hope you enjoy it.

 

What is MSAgent

Microsoft® Agent is a set of programmable software services that supports the presentation of interactive animated characters within the Microsoft Windows® interface. Microsoft Agent enables software developers and Web authors to incorporate a new form of user interaction, known as conversational interfaces, that leverages natural aspects of human social communication. In addition to mouse and keyboard input, Microsoft Agent includes optional support for speech recognition so applications can respond to voice commands. Characters can respond using synthesized speech, recorded audio, or text in a cartoon word balloon.

What you need

You can use MSAgent in several programming environments, VB, VC++ , Java and HTML. We will be exploring all four in this tutorial. But in order to use MSAgent you must have several items on your computer, if you do not have these items don't worry you can download then off Microsoft's site for free.

You can download these files here. They total approximately 9MB.

 

Lets get started

So lets get started with our first program, we will be using the Merlin character. So start up VB and add the Agent control to your form and add the code below.

Private Sub Form_Load()
Dim MSAgent As IAgentCtlCharacterEx
Dim Character As String

Character= "Merlin"
Agent1.Characters.Load Character, Character & ".acs"
Set MSAgent = Agent1.Characters(Character)
MSAgent.MoveTo 300, 150
MSAgent.Show
MSAgent.Speak "How are you today"
MSAgent.SoundEffectsOn = True
MSAgent.Hide
End Sub

What does all that code mean?

  1. Dim MSAgent As IAgentCtlCharacterEx - This is the Agent Object that we need to create.
  2. Dim Character As String - This is the string that will hold the name of our characters. This way we don't have to Dim each character.
  3. Character= "Merlin" - This is the character we will be using, Microsoft comes with 4 character, Merlin, Robby, Genie and Peedy. You can get other characters around the web or you can create your own. More on that later.
  4. Agent1.Characters.Load Character, Character & ".acs" - This line of code loads the character we specified in the "Character" string. using the Character & ".acs" will tell VB to look for Merlin in the default directory which is . Windows\Msagnet\Chars.
  5. Set MSAgent = Agent1.Characters(Character) - assign an object reference to a variable.
  6. MSAgent.MoveTo 300, 150 - This will move Marlin 300 pixels over and 150 pixels down when Merlin loads.
  7. MSAgent.Show -  This code show the Merlin character.
  8. MSAgent.Speak "How are you today" - This is what Merlin will say when it loads.
  9. MSAgent.SoundEffectsOn = True - This turns the sound effects on and off
  10. MSAgent.Hide - Merlin will disappear

     

Animations

All Agents come with standard animations, such as "load" or "hide".  For the Merlin character, the following animations exist:

Acknowledge
Alert
AlertReturn
Announce
AnnounceReturn
Blink
Confused
ConfusedReturn
Congratulate
CongratulateReturn
Congratulate_2
Decline
DeclineReturn
DoMagic1
DoMagic2
DoMagicReturn
DontRecognize
DontRecognizeReturn
Explain
ExplainReturn
GestureDown
GestureDownReturn
GestureLeft
GestureLeftReturn
GestureRight
GestureRightReturn

GestureUp GestureUpReturn
GetAttention
GetAttentionReturn
GlanceDown
GlanceLeft
GlanceRight
GlanceUp
Greet
GreetReturn
Hear_1
Hear_2
Hear_3
Hear_4
Hide
Idle1_1
Idle1_2
Idle1_3
Idle1_4
Idle2_1
Idle2_2
Idle3_1
Idle3_1Return
Idle3_2
LookDown

 

LookDownBlink
LookDownReturn
LookLeft
LookLeftBlink
LookLeftReturn
LookRight
LookRightBlink
LookRightReturn
LookUp
LookUpBlink
LookUpReturn
MoveDown
MoveDownReturn
MoveLeft
MoveLeftReturn
MoveRight
MoveRightReturn
MoveUp
MoveUpReturn
Pleased
PleasedReturn
Processing*
ProcessingReturn
Read
ReadContinued
ReadReturn

 

Reading*
ReadingReturn
RestPose
Sad
SadReturn
Searching*
SearchingReturn
Show
StartListening
StartListeningReturn
StopListening
StopListeningReturn
Suggest
SuggestReturn
Surprised
SurprisedReturn
Think
ThinkReturn
Uncertain
UncertainReturn
Wave
WaveReturn
Write
WriteContinued
WriteReturn
Writing*
WritingReturn

 

You can get the animations for the other 3 characters at the links below. Over the next 4 weeks we will be using animations and commands to manipulate MSAgent.

Animations for Genie Character
Animations for Robby Character
Animations for Peedy Character

 

Commands

Play

Using the play command the character will mimic what's in the quotes, below are some of the commands you can use with Play.

Play (Actions)

Play (Facial expressions)

These command will display facial expressions on the characters face.

This is just a few of the Play commands and what they can do, downloading the animations will give you the full list for each character.

Speak

You use the speak command when you want your character to speak. It will say anything with in the quotes. Of course you have to have download and installed the Text-toSpeach program.

MSAgent.Speak "Hello everyone"

Think

This command will use the bubble to show the text.

MSAgent.Think "I wonder what they said"

Movement

This command will move your character to the position specified in the MoveTo command.

MSAgent.MoveTo 300,150

 

Speech Output Tags

The speech output tags has the following  tags. These tags are are primarily designed for adjusting text-to-speech. Only the Mrk and Map tags can be used with sound file-based spoken output.

  • Chr - Sets the character of the voice - String that excepts the following,  "Normal", "Monotone" and "Whisper".
  • Ctx - Sets the context of the output text. - String that excepts the following, "Address", "Email", "Unknown".
  • Emp -Emphasizes the next word spoken. This tag must immediately precede the word. The syntax is \Emp\ ("\Emp\Hello there")
  • Lst - Repeats last spoken statement for the character. The syntax is \Lst\ ("Hello \Lst\there")
  • Map - Maps spoken text to text displayed in the word balloon. The syntax is \Map="spokentext"="balloontext"\
  • Mrk - Defines a bookmark in the spoken text. The syntax is \Mrk=number\
  • Pau - Pauses speech for the specified number of milliseconds. The syntax is \Pau=numberbetween 10 to 2550 milliseconds.
  • Rst - Resets all tags to the default settings The syntax is \Rst\
  • Spd - Sets the baseline average talking speed of the speech output The syntax is \Spd=number\ . The number is between 50 - 250.
  • Vol - Sets the baseline speaking volume of the speech output. The syntax is \Vol = Number\. The number is between 0 -65535.
  • Examples:

    MSAgent.Speak "\Chr=""Whisper""\Good evening everyone"'Since the Speak command also accepts strings you have to use double quotes for the Whisper command.

    MSAgen.Speak "\Ctx=""Address""Test@Test.com-The character will speak the name of the email address instead of spelling com and leaving out the dot.

     

    More Code Samples

    This sample code retrieves a list of all the animantions for each of the characters .

    Private Sub Form_Load()
    Dim MSAgent As IAgentCtlCharacterEx
    Dim Animation As Variant
    Dim char As String

    char = "Peedy"
    Agent1.Characters.Load char, char & ".acs"
    Set MSAgent = Agent1.Characters(char)

    For Each Animation In Agent1.Characters(char).AnimationNames
    List1.AddItem Animation
    Next
    End Sub

    To get Robby or Genie's animations just exchange the char name.

    This code shows you how to use the Request, Wait, LookRight and LookLeft properties. It appears that the two characters are having a conversation.

    Private Sub Form_Load()
    Dim Merlin As IAgentCtlCharacter
    Dim Genie As IAgentCtlCharacter
    Dim MerlinRequest As IAgentCtlRequest
    Dim GenieRequest As IAgentCtlRequest
    Dim Anim, Anim2 As String

    Anim = "Merlin"
    'Load Character 1
    Agent1.Characters.Load Anim, Anim & ".acs"

    Set Merlin = Agent1.Characters("Merlin")

    'Load Character 2
    Anim2 = "Genie"
    Agent1.Characters.Load Anim2, Anim2 &".acs"

    Set Genie = Agent1.Characters("Genie")

    'Move Merlin so the two characters are not on top of each other
    Agent1.Characters("Merlin").Left = 400

    'Make Merlin Appear
    Set MerlinRequest = Merlin.Show
    Genie.Wait MerlinRequest

    'Make Genie Appear
    Set GenieRequest = Genie.Show
    Merlin.Wait GenieRequest

    'Make Merlin look to his right and then Speak
    Merlin.Play "LookRight"
    Set MerlinRequest = Merlin.Speak ("I Genie how are you doing today?")
    Genie.Wait MerlinRequest

    'Make Genie look to his left and then Speak
    Genie.Play "LookLeft"
    Set GenieRequest = Genie.Speak _
    ("Just fine Merlin, thanks for asking")
    Merlin.Wait GenieRequest

    Merlin.Hide
    Genie.Hide
    End Sub

     

    Voice Activation

    While I was doing research on MS Agent I thought it would be great to use MS Agent to launch programs by just saying the program. The code below demonstrates how you can use MS Agent for voice recognition.

    Option Explicit

    Private Sub Form_Load()
    Dim AgentChar As IAgentCtlCharacterEx

    MSAgent.Characters.Load "DefaultCharacter"
    Set AgentChar = MSAgent.Characters("DefaultCharacter")
    AgentChar.Commands.Add "Notepad", "Notepad", "Notepad", True, True
    End Sub

    Private Sub MsAgent_Command(ByVal UserInput As Object)
        Shell "Notepad.exe", vbNormalFocus
    End Sub

    When you run the program click on the Scroll Lock key and say "Merlin". When Merlin appears hold down the Scroll Lock key again and say Notepad and the program will launch. Imagine the possibilities!

    What does AgentChar.Commands.Add "Notepad", "Notepad", "Notepad" mean?

    The first parameter listed above is the name  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

    If you wanted to be able to say, "Open Notepad Please" and still have it reconize that statement means the same as just saying "Notepad" you must use ellipses in brackets. This tells the Text-to-Speach engine to ignore any speach before and after Notepad.

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

     

    Getting to know the characters expressions

    Now that we have created some basic animations using MS Agent, lets get to know more of the characters expressions and other commands. If you have VB5/6, VC++ 5/6 or VJ++ download and run the project below. You can see how the characters react to commands as will has speak and move.

    MSAgent Sample - Samples in VB, C++ & VJ++

     

    Whats next

    We have gone over the basics of the MS Agent technology. You should be able to find out all the animations the characters do. But you may be wondering what is the technology good for. I will show you sites and samples of application made using MS Agnet to give you some ideals on how to use or incorporate this technology in your own programs.

    Applications using MS Agent Technology

    Mindbeat - Mindbeat uses Microsoft Agent Technology to create several talking applications including a talking mailbox and a talking winamp application.

    4Developers - 4Developers uses Microsoft Agent Technology to create a talking stock quote software.

    MS Office Sample Then you have Microsoft that has provided a sample using MS Agent with powerpoint.

     

    More Applications

    PopAgent - PopAgent is a mail program using the MS Agent technology.

    Talkingbuddy - Talkingbuddy uses MS Agent technology to read mail, stock quotes, news and web pages.

    http://www.beebot.com/agent/ - Deebot allows you to send e-Grams(greeting cards) using MS Agent technology.

    Learning a Language

    The site below uses MS Agent to teach you how to speak the Mohawk language. You can either type in the word or us you mic to say the word you wish to here and the character will translate it to Mohawk.

    http://www.buycny.com/msagent/mohawk.shtml

    We are getting down to the end of this tutorial, so I thought it would be a good time to introduce you to sites that provide free characters. If you either downloaded CapMFC or MSAgentExp or have compiled these programs you will get all the animations that these characters do.

    http://www.msagentring.org/chars/

    http://www.msagent.co.uk/characters.html

     

    Conclusion

    While writing this tutorial I thought of several things that MSAgent can do. It would be a great tool to use on your web site if you wanted to make your site accessible to sight impaired visitors. Or how about using it in conjunction with your help files, the application can be endless.

    Resources

    Creating Characters for Microsoft Agent

    Guidelines for Designing Character Interaction
    http://msdn.microsoft.com/workshop/imedia/agent/guidelines.asp

    Designing Characters for Microsoft Agent
    http://msdn.microsoft.com/workshop/imedia/agent/deschar.asp

    Using the Microsoft Agent Character Editor
    http://msdn.microsoft.com/workshop/imedia/agent/charactereditor.asp

    Using the Microsoft Linguistic Information Sound Editing Tool
    http://msdn.microsoft.com/workshop/imedia/agent/liset.asp

    MSAgent NewsGroup
    microsoft.public.msagent

    Microsoft Agent Ring
    http://www.msagentring.org/

    Agent books

    Books

    Copyright© 2001 Marietta Crockett
    Disclaimer