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.
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.
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
mSpk = AxAgent1.Characters("Peedy")
Dim Enume As IEnumerator = _
ComboBox1.Text = ComboBox1.Items.Item(0)
The code for "Show" button
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
The code for "Hide" button
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
The code for "Exit" button
Private Sub Button5_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button5.Click
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
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
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
mSpk.MoveTo(Convert.ToInt16(Cursor.Position.X - 60), _
Convert.ToInt16(Cursor.Position.Y - 60))
Do not forget, these characters' speech are sensitive to punctuation marks such as ",", "?", "!",...etc. Try and enjoy!..
- 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.
In your applications, you can use your creativity and features of these characters to make more interactive applications.
Have a nice day!