Online College Courses for Credit

Sample Program: Text to Voice

Sample Program: Text to Voice

Author: Lilian Dyer

To learn the anatomy of a C# program. To learn about the files the IDE creates to run a program. To study some sample code to produce voice from text.

You will use Microsoft Visual C# Express 2010 to write this program. This Windows Forms Application sample code actually runs. It uses the new namespace System.Speech.Synthesis to produce voice from text. You will create a form or GUI to interact with the user where the user will enter any text and when pressing the "Speak to me!!" button the user will hear the phrase or sentence she entered.

See More
Fast, Free College Credit

Developing Effective Teams

Let's Ride
*No strings attached. This college course is 100% free and is worth 1 semester credit.

37 Sophia partners guarantee credit transfer.

299 Institutions have accepted or given pre-approval for credit transfer.

* The American Council on Education's College Credit Recommendation Service (ACE Credit®) has evaluated and recommended college credit for 33 of Sophia’s online courses. Many different colleges and universities consider ACE CREDIT recommendations in determining the applicability to their course and degree programs.


A note on Methods

What is the difference between parameters and arguments? They are called parameters when they are defined as values that can be passed to a method.  They are called arguments when a method is called and you pass values to it.

Example of Method definition:

public static int BlahBlahBlah(string thingToSay, int numberOfTimes)


   //  statements go here...

  return value



Example of calling this same method:

int size = BlahBlahBlah("Hello World!", 3);

This method is passing two arguments: 1) The first argument is "Hello World!" of type string; 2) The second argument is a number 3 of type int.

MessageBox.Show("This is an argument");

When you call a method the arguments must be the same type as the types of the parameters. The number of arguments depends on the number of parameters. So a method could have any number of parameters or no parameters at all.

How to Add the System.Speech

  • Go to the Solution Explorer window
  • Right Click on References
  • Choose Add Reference...
  • Choose the tab .NET
  • Scroll down until you find System.Speech
  • Click OK

The Anatomy of a C# Program


This is the program running...