SpeakComputers.com
Home
Software
Electronics
Desktop Computers
Laptops
Games
Handheld Devices
Mobile Phones
Cameras
Camcorders
Printers
Books
Software Downloads 2012 Software Mac Software Security Student Editions Windows 7 Office 2010
ASP.NET C# VB.NET C++ .NET Infragistics DevComponents

Text to Speech, System.Speech.

The Microsoft .Net Framewok version 3.0 introduces the long awaited System.Speech assembly. With the System.Speech assembly you can create speech enabled Windows applications including, Text to Speech and Speech recognition.

Namespace: System.Speech
Assembly: Systems.Speech.dll

using System.Speech;
Calling: System.Speech
Requirements: .Net FrameWork 3.0

Download the complete project here. Requirements, VisualStudio 2005 and .Net 3.0

Creating Speech enabled Windows applications could not be easier. To prove to you just how easy it is, lets create a simple yet powerful Text to Speech application. We are going to create a Single document interface, add a menu, context menu, status bar and use a richtextbox control for our textarea.

To start, open Visual Studio 2005, create a new Windows c# project. Add a reference to the System.Speech assembly. On Form1 or mainForm add a statusBar, context menu, MenuStrip and a richTextBox which will be docked to fill the form.

Declare your SpeechSynthesizer speakRBox.
System.Speech.Synthesis.SpeechSynthesizer speakRBox = new System.Speech.Synthesis.SpeechSynthesizer();

On the MenuStrip, create Speak, Pause and Stop menu items. Create the Click events for the menu items just created. Under the Speak event add the following code.

if (speakRBox.State == System.Speech.Synthesis.SynthesizerState.Ready) { speakRBox.SpeakProgress += new EventHandler(speakRBox_SpeakProgress); speakRBox.SpeakCompleted += new EventHandler(speakRBox_SpeakCompleted); speakRBox.SelectVoice(toolStripComboBox1.SelectedItem.ToString()); speakRBox.SpeakAsync(this.richTextBox1.Text); return; } if (speakRBox.State == System.Speech.Synthesis.SynthesizerState.Paused) { speakRBox.Resume(); }

Under the Pause event, add the following code.

if (speakRBox.State == System.Speech.Synthesis.SynthesizerState.Speaking) { speakRBox.Pause(); this.toolStripStatusLabel1.Text = "Paused"; return; } if (speakRBox.State == System.Speech.Synthesis.SynthesizerState.Paused) { speakRBox.Resume(); } 

Under the Stop event.

if (speakRBox.State == System.Speech.Synthesis.SynthesizerState.Speaking) { speakRBox.SpeakAsyncCancelAll(); } 

Additional things to do.

You can add the feature of speaking the text to a wav file for later play back. To do this, add a menu item and create a click event. Under the click event add the following code.

speakRBox.SetOutputToWaveFile(@"c:\1.wav");
speakRBox.SpeakAsync("Hello World");
Computer Security
AntiVirus Software
Internet Security
Parental Controls
Backup & Recovery
Computer Protection
Anti Malware
Photo & Video
Photo & Video Editing
Video Music
Desktop Publishing
Professional Design
Home Publishing
Clipart
Business & Accounting
Accounting
Payroll
Check Printing
TAX
H&R Block
Microsoft Office
Design
Graphic Design
Home Design
Garden Design
Interior Design
Computer Aided Design
3D Design
Students & Teacher
Adobe
Microsoft Office
Dragon Naturally Speaking
Corel Draw
Serif
Student/Teacher Software
Copy Right 2006 SpeakComputers.com - All Rights Reserved.
Home About Privacy Policy Resouces