MSAGENT IN C#-Part2 SPEECH RECOGNITION(SR)


In this piece of writing let us see somefascinating characters which speak to us and support for speechrecognition. Let us see in detail.

Introduction to MICROSOFT AGENT:

The Microsoft Agent API provides services thatsupport the display and animation of animated characters. MicrosoftAgent includes optional support for speech recognition so applicationscan respond to voice commands. Characters can respond using synthesizedspeech, recorded audio, or text in a cartoon word balloon.

Requirements:

To be able to use this technology, you must have:

The Microsoft Agent Core components.
The Microsoft Agent Characters Genie, Merlin, Robby, and Peedy.
The Microsoft Speech API 4.0a runtime.
The Microsoft Speech Recognition Engine.
The Lernout and Hauspie Text-to-Speech engines for at least US English.

All these components are available from http://microsoft.com/products/msagent/downloads.htm.

Overview of Speech Recognition:

Speech recognition and text-to-speech useengines, which are the programs that do the actual work of recognizingspeech or playing text. Most speech-recognition engines convertincoming audio data to engine-specific phonemes, which are thentranslated into text that an application can use. (A phoneme is thesmallest structural unit of sound that can be used to distinguish oneutterance from another in a spoken language.)

Speech recognition is a bit more complex to categorize than text-to-speech.
Every speech recognition engine has three characteristics:

1. Continuous vs. discrete:

In continuous speech recognition, clients canspeak to the system naturally. In discrete, clients require to gapbetween each word. Clearly, continuous recognition is desired overdiscrete recognition, but continuous recognition needs more processingpower.

2. Vocabulary size:

Speech recognition can support a small orlarge vocabulary. Small-vocabulary recognition permits users to givesimple commands to their computers. To dictate a text, the system musthave large-vocabulary recognition.

3. Speaker Dependence:

Speaker-independent speech recognition worksproperly with out any training, while speaker-dependent systems requirethat each user spend about 30 minutes training the system to his or hervoice.

Msagent uses "Command and Control" speechrecognition which is continuous, small vocabulary, and speakerindependent. So the users can create several hundred different commandsor phrases. If a user says a command that is not in the list, thespeech-recognition system will return either "not recognized," or willthink it heard a similar-sounding command. For the reason that users ofCommand and Control can say only specific phrases, the phrases must beeither visible on the screen–so intuitive that all users will knowwhat to say–or the users must learn what phrases they can say.

THE COMMANDS WINDOW:

If an attuned speech engine is installed,Microsoft Agent supplies a special window called the Commands Windowthat shows the commands that have been voice-enabled for speechrecognition. The Commands Window serves as a visual prompt for what canbe spoken as input.

THE LISTENING TIP:

If speech is enabled, a special tool tipwindow appears when the user presses the push-to-talk key to beginvoice input. The Listening Tip displays contextual informationassociated to the current input state.

MSAGENT IN C# [ SPEECH RECOGNITION(SR)]

To use Msagent in C# we have to add two DLL files AxAgentObjects.dll and AgentObjects.dll in our program.

To add commands the code is simple as below

Character.Commands.Add("Who is your Master?",
(object)"Who is your Master?",
(object)"(Your(Master| Administrator))",
(object)true,
(object)true);

Similarlly from the below code we can see thataccording to the user voice input we can make commands. For example ifwe ask "Who is your Master?" to the character it responds to us insaying the answer. Likewise we can create any number of commands.

IAgentCtlUserInput ui;
ui = (IAgentCtlUserInput)e.p_userInput;
if(ui.Name == "Who is your Master?")
{

Character.Play ("Pleased");
Character.Speak((object)"My Master name is G.GNANA ARUN GANESH." +
" You can contact him through his mail ggarung@rediffmail.com.", null);

}

The Example:


using System;
using System.Drawing;
using System.WinForms;
using AgentObjects;

public class Speech : 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 Speech()
{
InitializeComponent();
}

public static void Main(string[] args)
{
Application.Run(new Speech());
}

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);

button1.Location = new System.Drawing.Point(88, 208);
button1.BackColor = (System.Drawing.Color)System.Drawing.Color.FromARGB((byte)255, (byte)128, (byte)128);
button1.Size = new System.Drawing.Size(152, 32);
button1.TabIndex = 1;
button1.Text = "Load character";

button2.Location = new System.Drawing.Point(120, 240);
button2.BackColor = (System.Drawing.Color)System.Drawing.Color.FromARGB((byte)255, (byte)128, (byte)128);
button2.Size = new System.Drawing.Size(96, 24);
button2.TabIndex = 2;
button2.Text = "SPEAK";

textBox1.Location = new System.Drawing.Point(48, 8);
textBox1.Text = " ";
textBox1.Multiline = true;
textBox1.TabIndex = 0;
textBox1.Size = new System.Drawing.Size(248, 200);
textBox1.BackColor = (System.Drawing.Color)System.Drawing.Color.FromARGB((byte)255, (byte)128, (byte)128);
this.Text = "MSAGENT DEMO";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.WindowState = System.WinForms.FormWindowState.Maximized;
this.BackColor = (System.Drawing.Color)System.Drawing.Color.FromARGB((byte)255, (byte)192, (byte)192);
this.ClientSize = new System.Drawing.Size(344, 301);
AxAgent.Command += new
AxAgentObjects._AgentEvents_CommandEventHandler(AxAgent_Command);

this.Co
ntrols.Add(button2);
this.Controls.Add(button1);
this.Controls.Add(textBox1);
this.Controls.Add(AxAgent);
button1.Click += new System.EventHandler(button1_Click);
AxAgent.EndInit();
}

protected void button2_Click(object sender, System.EventArgs e)
{
if(textBox1.Text.Length == 0)
return;
Character.Speak(textBox1.Text, null);
}
protected void button1_Click(object sender, System.EventArgs e)
{

OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.AddExtension = true;
openFileDialog.Filter = "Microsoft Agent Characters (*.acs)|*.acs";
openFileDialog.FilterIndex = 1 ;
openFileDialog.RestoreDirectory = true ;

if(openFileDialog.ShowDialog() != DialogResult.OK)
return;

try { AxAgent.Characters.Unload("CharacterID"); }
catch { }
AxAgent.Characters.Load("CharacterID", (object)openFileDialog.FileName);
Character = AxAgent.Characters["CharacterID"];
Character.LanguageID = 0×409;
Character.Show(null);

Character.Commands.Caption = "Sample Commands";

Character.Commands.Add("Who is your Master?",
(object)"Who is your Master?",
(object)"(Your(Master| Administrator))",
(object)true,
(object)true);

Character.Commands.Add("Exit",
(object)"Exit",
(object)"(exit | close | quit)",
(object)true,
(object)true);

Character.Play ("announce");
Character.Speak ("welcome you sir",null);

}

protected void AxAgent_Command(object sender, AxAgentObjects._AgentEvents_CommandEvent e)
{
IAgentCtlUserInput ui;
ui = (IAgentCtlUserInput)e.p_userInput;
if(ui.Name == "Who is your Master?")
{

Character.Play ("Pleased");
Character.Speak((object)"My Master name is G.GNANA ARUN GANESH." +
" You can contact him through his mail ggarung@rediffmail.com.", null);

}
if(ui.Name == "Exit")
{
Character.Speak((object)"Good bye", null);

Character.Play("Wave");
Character.Play("Hide");
}
}

}

The output:

About the Author:

G.GNANA ARUN GANESH is Admin and the founderof www.onlinecsharpteach.netfirms.com. He has been programming in C,C++, Visual Basic, COM for 3 years. Arun's background includes Bachelordegree in ECE. He is an Active person in the panel of TechnicalReviewers in Prentice Hall Publishers and Sams Publishers. He is alsowriting articles particularly in C# in various websites. For moreinformation visit www.geocities.com/arunganeshgg/index.html.

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!