Click here to Skip to main content
Click here to Skip to main content

The Usage of Microsoft Agent Control in VB.NET Applications

, 5 Oct 2005
Rate this:
Please Sign up or sign in to vote.
How to use Microsoft Agent Control in your VB.NET applications to make them more interactive.

Introduction

Microsoft Agent is a technology used to add interactive animated characters to Windows applications.

When you use the Microsoft Agent control, you can access four predefined characters which are Genie, Merlin, Peedy, and Robby. Each character has a different set of animations.

The Microsoft Agent control uses a text-to-speech engine and speech recognition engines. When the user speaks, the control uses a speech recognition engine and translates the input sound into computer understandable form. In the mean time, the control uses a text-to-speech engine to generate the characters to speak the words which are typed in by the user.

Background

In this article, the character "Peedy" and a text-to-speech engine are used. Because of that, you will need to download the necessary files from the Microsoft web site to run this sample application. Moreover, if you are thinking of developing Windows applications using this control, you will need these files. You can download these files from the link below:

You need to download the "Microsoft Agent character file" (if you need to run the sample in this article alone, you only need "Peedy.exe", but you can download the other character files for future application development), "Text-to-Speech engine file", and also you might need the "SAPI 4.0 runtime file".

If you want to use the speech recognition feature of the control in your future application development, you will need the "Speech recognition engine file" as well.

You can find all these downloadable files from the link above.

Implementation

In this section, I have tried to give a brief description of the procedures which are used in the sample application.

The code for Form Load

In this procedure, we are loading the character "Peedy" and filling the combo box with its animation types. Because, we will select the animation type from the combo box and animate the character while we are running the sample program. Note that if you would like to use another character, you should change the parameter "Peedy" to "Genie"/"Merlin"/"Robby" in this procedure. Moreover, you will need one more change. It is for the content of the text box that shows the location of an agent control file in your hard drive. For example, if you use the character "Genie", the program will need "Genie.acs" file and you should change the content of the text box to "C:\WINDOWS\msagent\chars\Genie.acs". That's all you for this!

Private Sub Form1_Load(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles MyBase.Load

    AxAgent1.Characters.Load("Peedy", TextBox2.Text)
    'Set current character to Peedy and show it
    mSpk = AxAgent1.Characters("Peedy")

    Dim Enume As IEnumerator = _
      AxAgent1.Characters.Character(mSpk.Name).AnimationNames.GetEnumerator()

    While Enume.MoveNext
        ComboBox1.Items.Add(Enume.Current)
    End While

    'To show the first event name instead of the text "Combobox1"
    ComboBox1.Text = ComboBox1.Items.Item(0)
End Sub

The code for "Show" button

Private Sub Button1_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button1.Click
    mSpk.Show(0)
End Sub

The code for "Hide" button

Private Sub Button4_Click(ByVal sender As System.Object, _
           ByVal e As System.EventArgs) Handles Button4.Click
    mSpk.Hide()
End Sub

The code for "Exit" button

Private Sub Button5_Click(ByVal sender As System.Object, _
           ByVal e As System.EventArgs) Handles Button5.Click
    End
End Sub

The code for "Animate" button

In this procedure, the program makes the character to play selected animations in the combo box.

Private Sub Button2_Click(ByVal sender As System.Object, _
               ByVal e As System.EventArgs) Handles Button2.Click
    'Stop the previous action to start new one
    mSpk.Stop()
    'Play the new action
    mSpk.Play(ComboBox1.Text)
    'Turn to rest position
    mSpk.Play("RestPose")
End Sub

The code for "Talk" button

In this procedure, the program makes the character to speak typed words in the text box. Note that you can change the text while the program is running.

Private Sub Button3_Click(ByVal sender As System.Object, _
                ByVal e As System.EventArgs) Handles Button3.Click
    'Stop the previous action to start new one
    mSpk.Stop()
    'Speak the text
    mSpk.Speak(TextBox1.Text)
End Sub

The code for "MOVE HERE" button

In this procedure, the program makes the character to move to the position of the current mouse pointer.

Private Sub Button6_Click(ByVal sender As System.Object, _
             ByVal e As System.EventArgs) Handles Button6.Click
    'Stop the previous action to start new one
    mSpk.Stop()
    'Let the character to move to the position of current mouse pointer
    mSpk.MoveTo(Convert.ToInt16(Cursor.Position.X - 60), _
                Convert.ToInt16(Cursor.Position.Y - 60))
End Sub

Do not forget, these characters' speech are sensitive to punctuation marks such as ",", "?", "!",...etc. Try and enjoy!..

Important Points

  • Before you run the sample application or develop your own application, you should install the necessary files which are described in the Background section.
  • Before you start to write your own code, you should add "Microsoft Agent control 2.0" into your toolbox and then to your form.

Last Words!

In your applications, you can use your creativity and features of these characters to make more interactive applications.

Have a nice day!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Yiltan Bitirim
Instructor / Trainer
Turkey Turkey
Asst. Prof. in Eastern Mediterranean University.

Comments and Discussions

 
Questionmultilanguage support how? Pinmember29181195-Mar-09 1:57 
Questionhow to keep the caracter inside a child form or a label Pinmemberjathoo20-Oct-07 5:41 
QuestionMs agent speech recognition [modified] Pinmemberamitairos21-Aug-06 23:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 5 Oct 2005
Article Copyright 2005 by Yiltan Bitirim
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid