65.9K
CodeProject is changing. Read more.
Home

Computer Talker with C#

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.45/5 (44 votes)

Nov 12, 2014

CPOL
viewsIcon

59323

downloadIcon

981

Write a program to make your computer talk for you.

Introduction

Write a simple program to make your computer talk for you.

Using the Code

  1. Add a textbox named 'txtWords' to a form.
  2. Add a button named 'btnSpeak' to a form.
  3. Add a reference to System.Speech.
  4. In the form's code-behind, add:
    using System.Windows.Forms;
    using System.Speech.Synthesis;
    
    namespace Sample
    {
     public partial Class Form1: Form
     {
      public SpeechSynthesizer _synthesizer;
      private void btnSpeak_Click(object sender, EventArgs e)
      {
       _synthesizer = new SpeechSynthesizer();
       var words = txtWords.Text;
       _synthesizer.Speak(words);
      }
      public Form1()
      {
       InitializeComponent();
      }
     }
    }
  5. Run. Text entered into the textbox will be spoken by the computer.