MSAGENT In C#-Part1 [Text To Speech (TTS)]
In this piece of writing let us see someintriguing characters which speak to us using synthesized speech,recorded audio, or text in a cartoon word balloon. It even support forspeech recognition. Let us see in detail.
INTRODUCTION TO MICROSOFT AGENT:
The Microsoft Agent API affords services thatsupport the display and animation of animated characters. MicrosoftAgent consists of optional support for speech recognition as a resultapplications can respond to voice commands. Characters can react usingsynthesized speech, recorded audio, or text in a cartoon word balloon.
REQUIREMENTS:
To be proficient to use this technology, we 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.
SKETCH OF SPEECH TECHNOLOGIES:
Text-to-speech is the capability of a computerto translate text information into synthetic speech output. Speechrecognition is the capability of a computer to recognize the spokenword for the purpose of receiving command and data input from thespeaker.
Speech recognition and text-to-speech make useof engines, which are the programs that do the real work of recognizingspeech or playing text. Nearly all speech-recognition engines translateincoming audio data to engine-specific phonemes, which are theninterpreted 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.)
TWO TYPES OF TEXT-TO-SPEECH:
1. Synthesized text-to-speech
2. Concatenated text-to-speech.
SYNTHESIZED TEXT-TO-SPEECH:
In Synthesized speech the words are examinedand produce the phonetic pronunciations for the words. The phonemes arethen moved into a complex algorithm that imitates the human vocal tractand produce the sound.
CONCATENATED TEXT-TO-SPEECH:
In Concatenated text-to-speech it studies thetext and pulls recordings, words, and phrases out of a prerecordedlibrary. The digital audio recordings are concatenated.
SPEECH APPLICATION PROGRAMMING INTERFACE:
The Microsoft Speech Application ProgrammingInterface (API) uses the OLE Component Object Model (COM) architectureunder Win32 (Windows 95 and Windows NT). Microsoft Agent's architectureuses Microsoft SAPI for synthesized speech output. Microsoft Agent usesthe Microsoft Speech Application Programming Interface (SAPI) tosupport speech input (speech recognition, or SR) and speech output(text-to-speech, or TTS). Microsoft Agent describes interfaces thatpermit applications to access its services, enabling an application tocontrol the animation of a character, support user input events, andspecify output.
THE CHARACTER WINDOW:
In Microsoft Agent applications the animatedcharacters are displayed in their individual windows that always appearat the top of the window z-order. A user can move a character's windowby dragging the character with the left mouse button. The characterimage moves with the pointer.
THE WORD BALLOON:
In addition to spoken audio output, thecharacter also supports textual captioning in the form of text outputin cartoon-style word balloons. Words show in the balloon as they arespoken. The balloon hides from view when spoken output is completed.
MICROSOFT AGENT IN WEB PAGES
To use the Microsoft Agent services in a Webpage, use the HTML <OBJECT> tag within the <HEAD> or<BODY> element of the page, specifying the Microsoft CLSID (classidentifier) for the control. In addition, use a CODEBASE parameter tospecify the location of the Microsoft Agent installation file and itsversion number.
We can use Vbscript,JavaScript and JScript to program the Microsoft Agent in Web pages.

USING MICROSOFT AGENT WITH THE .NET FRAMEWORK:
Microsoft Agent is available as an ActiveXcontrol DLL. To utilize it within .NET, you can use the AxImp.exeutility provided with the .NET Framework SDK.
AxImp –>> ActiveX Control to Win Forms Assembly Generator.
Syntax: AxImp [/? | [[/source] OCXName]]
Aximp agentctl.dll
The above command creates two files namelyAxAgentObjects.dll and AgentObjects.dll. With the use of above twofiles we are now geared up to utilize Agent with .NET.
Microsoft Agent in C#.
To use Msagent in C# we have to add two DLLfiles AxAgentObjects.dll and AgentObjects.dll in our program. To loadthe character the code 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 = 0×409;
//This code displays the character.
Character.Show(null);
To speak some Text the code is as follows:
Character.Speak ("Welcome you sir VISIT www.onlinecsharpteach.netfirms.com ",null);
Now let us see an example:
The Example:
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);
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);
this.Controls.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.Play ("announce");
Character.Speak ("welcome you sir",null);
}
}
The Output:

Conclusion:
The Microsoft Agent API offers services thatsupport the display and animation of animated characters. Implementedas an OLE Automation (Component Object Model [COM]) server, MicrosoftAgent facilitates multiple applications, called clients or clientapplications, to host and access its animation, input, and outputservices at the same time.
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.












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