A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Speaking Computer in C#This short tutorial will show you how to make your computer talk. This is very useful for error messages, other warnings or errors the user should be aware of. |
On Thursday, May 17th 2007 at 10:07 PM By Ryan Turney (View Profile) ![]() ![]() ![]() ![]() (Rated 4.9 with 26 votes) |
||
This is very simple to accomplish, we will be using Windows SAPI (Speech Application Program Interface) along with Microsoft’s Visual C# 2005 Express Edition. Our application will contain a text box that the user will be able to input text into and then push a button that will tell the application to read everything in the text box, very simple.
First off, you will need to create a new Windows Project and create a textbox and a button right below it, like so. Be sure to set multiline to true when creating this.
Next, we need to add a reference to the SAPI. To do this, right click your project in the Solution Explorer and click on Add Reference. Once that window appears click on the COM tab, locate "Microsoft Speech Object Library" and click ok.
Now for the final step, the code. using System; using System.Windows.Forms; // You need this so you can use functions from the SAPI using SpeechLib; namespace SAPI { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { // Creates a new instance of SpVoice SpVoice voice = new SpVoice(); // Tells the program to speak everything in the textbox using Default settings voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFDefault); } } } Now build the application and test it out, if everything was coded correctly you should hear the computer speak everything you typed into the textbox. It's really that simple! There is so much more that you can do with this, this is just to give you a little push in the right direction. Good Luck! |
|||
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|||
|
|||
Current CommentsThanq very much... I am beginner in C# and ur example made me sm more confident..
plz be continue with this type of examples...
- Vamshi
Hi,Thanks a lot....Its really helpful..I am a beginner in learning C#..
Amazing, I can\'t belive... really useful in every windows application.. i am going to implement same one.
so please update with all new things in .net 2.0
Thanks a lot!!!
oh!! i am getting this error :Exception from HRESULT: 0x8004503A
please help me how can i solve this???
Great tutorial, Ryan!
When can we expect another one?
i also got this Exception : - HRESULT: 0x8004503A
I did everything exectly, but COM class not registered came up on the mobile device. Can\'t get around this error, does anyone know what to do to fix this error ?
Pretty good C# tutorial, i really liked it. Please continue with more interesting tutorials.
Very nice, added a bit of AHH to my class project
Thanks
When I ran it, I got an Exception : - HRESULT: 0x8004503A
weee, nice, imm gooing to use this to listen to the other tuts =) dont have to read anymore, sw33t =)
.NET 3.0 includes the Speech.* namespaces that make TTS a bit easier. See this article:
http://www.ravib.com/dotnetbits/article.050.TTS.htm
Cheers,
-- Ravi
hi
I am a beginner in C#
your tutorial\'s make it to easy to learn this language
Now I am gating a problem in windows programming.
when i maximize the form it get full screen but it\'s component does not follow it . they still in there previous state !
what can i do for that .
pls help me i am doing a collage project
& sorry for my bad english
hello,
for Nabil: use "DOCK" for those component from the properties list of each component.:)
have a nice day
Really its a simple n easy code, good work ,thanks for ur code
nice work and its really helpful for all of us which are begniers in C#..
thanks alot ..and keep it up
it is very nice C# tutorial but i need to find out how can i can use this application in my national language?
I get an error at compile time saying that the name "InitializeComponent" doesn't exist in the current context.
Where is the code for that method? What am I missing?
Thanks for your help!
Never mind! I had the tutorial code in Program.cs, when I put it in Form1.cs, it worked fine.
Thanks for the tutorial!
Thanks for this example!! It just boosted my confidence!
Exception from HRESULT: 0x80045009
i m getting this error . while using windows server 2003. i installed speech kit 5.1 in server, i m getting same error
any solution?
wow...dude...this is awesome
fuck
can you do on the Pocket PC ?
Thanh?
quangcanh.dhv@gmail.com
Related Tutorials
Related Source Code
C# Job Search