Did you know that you can use characters like the animated Microsoft Office paperclip in your own applications? In this article Gnana shows us how, using the MSAgent control and C#...
Working With Speech Using the MSAgent in C# - Microsoft Agent in C# (Page 3 of 5 )
To use MSAgent in C#, we have to add two DLL files to our project: AxAgentObjects.dll and AgentObjects.dll. The code to actually create and load an MSAgent character is simple:
AxAgent.Characters.Load("Genie",(object)"C:/Windows/Msagent/chars/GENIE.acs"); Character = AxAgent.Characters["Genie"];
//To set the language to US English. Character.LanguageID = 0x409;
//This code displays the character. Character.Show(null);
// Speak some text Character.Speak ("Hello, how are you?",null);
Let's now look at a complete working example written in C#:
using System; using System.Drawing; using System.WinForms; using AgentObjects;
public class Hello: Form { private System.ComponentModel.Container components; private System.WinForms.Button button2; private System.WinForms.Button button1; private System.WinForms.TextBox textBox1; private AxAgentObjects.AxAgent AxAgent;
private IAgentCtlCharacterEx Character;
public Hello() { InitializeComponent(); }
public static void Main(string[] args) { Application.Run(new Hello()); }
private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.button1 = new System.WinForms.Button(); this.button2 = new System.WinForms.Button(); this.textBox1 = new System.WinForms.TextBox(); this.AxAgent = new AxAgentObjects.AxAgent();
AxAgent.BeginInit();
button2.Click += new System.EventHandler(button2_Click);