Click here to Skip to main content
15,941,444 members
Articles / Programming Languages / C#
Tip/Trick

Computer Talker with C#

Rate me:
Please Sign up or sign in to vote.
4.05/5 (28 votes)
12 Nov 2014CPOL 45.1K   527   24   25
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:
    C#
    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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Oproot Research
United States United States
+ Oproot Research
Learn all that is learnable.

Comments and Discussions

 
GeneralMy vote of 5 Pin
WeaselWes15-Nov-14 5:16
WeaselWes15-Nov-14 5:16 
QuestionShort, Sweet and to the Point Pin
StevieLee14-Nov-14 4:12
StevieLee14-Nov-14 4:12 
AnswerRe: Short, Sweet and to the Point Pin
Oproot Research14-Nov-14 5:36
Oproot Research14-Nov-14 5:36 
AnswerRe: Short, Sweet and to the Point Pin
User 1106097915-Nov-14 0:38
User 1106097915-Nov-14 0:38 
QuestionWhy the class level SpeechSynthesizer variable? Pin
spencepk13-Nov-14 9:53
spencepk13-Nov-14 9:53 
AnswerRe: Why the class level SpeechSynthesizer variable? Pin
Oproot Research13-Nov-14 11:12
Oproot Research13-Nov-14 11:12 
GeneralMy vote of 2 Pin
Tammam Koujan12-Nov-14 21:32
professionalTammam Koujan12-Nov-14 21:32 
GeneralRe: My vote of 2 Pin
aeastham13-Nov-14 2:23
aeastham13-Nov-14 2:23 
GeneralRe: My vote of 2 Pin
Tammam Koujan13-Nov-14 3:22
professionalTammam Koujan13-Nov-14 3:22 
GeneralRe: My vote of 2 Pin
Oproot Research13-Nov-14 7:41
Oproot Research13-Nov-14 7:41 
GeneralMy vote of 5 Pin
Humayun Kabir Mamun12-Nov-14 17:39
Humayun Kabir Mamun12-Nov-14 17:39 
GeneralMy vote of 1 Pin
emrea12-Nov-14 8:56
emrea12-Nov-14 8:56 
GeneralMy vote of 5 Pin
Mahsa Hassankashi12-Nov-14 8:38
Mahsa Hassankashi12-Nov-14 8:38 
GeneralMy vote of 5 Pin
User 1106097912-Nov-14 8:15
User 1106097912-Nov-14 8:15 
GeneralRe: My vote of 5 Pin
Oproot Research12-Nov-14 8:26
Oproot Research12-Nov-14 8:26 
GeneralMy vote of 4 Pin
newton.saber12-Nov-14 7:48
newton.saber12-Nov-14 7:48 
GeneralRe: My vote of 4 Pin
Oproot Research12-Nov-14 8:27
Oproot Research12-Nov-14 8:27 
SuggestionNice tip! Pin
Afzaal Ahmad Zeeshan12-Nov-14 7:46
professionalAfzaal Ahmad Zeeshan12-Nov-14 7:46 
GeneralMy vote of 2 Pin
Mladen Borojevic19-Mar-14 23:02
professionalMladen Borojevic19-Mar-14 23:02 
QuestionJust basic stuff :) Pin
MaskedDev19-Mar-14 6:20
professionalMaskedDev19-Mar-14 6:20 
AnswerRe: Just basic stuff :) Pin
Oproot Research12-Nov-14 7:36
Oproot Research12-Nov-14 7:36 
GeneralMy vote of 2 Pin
Sacha Barber19-Mar-14 2:56
Sacha Barber19-Mar-14 2:56 
GeneralRe: My vote of 2 Pin
User 1106097912-Nov-14 6:38
User 1106097912-Nov-14 6:38 
QuestionAlso see... Pin
Ravi Bhavnani18-Mar-14 19:21
professionalRavi Bhavnani18-Mar-14 19:21 
AnswerRe: Also see... Pin
Oproot Research12-Nov-14 7:34
Oproot Research12-Nov-14 7:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.