Click here to Skip to main content
16,015,040 members
Articles / Programming Languages / C#
Tip/Trick

Computer Talker with C#

Rate me:
Please Sign up or sign in to vote.
3.99/5 (40 votes)
28 Sep 2024CPOL 51.8K   755   30   31
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
Teraten
United States United States
+ Teraten
Plan your next win with Teraten.

Comments and Discussions

 
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
Teraten12-Nov-14 7:36
Teraten12-Nov-14 7:36 
AnswerRe: Just basic stuff :) Pin
haughtonomous30-Sep-24 4:32
haughtonomous30-Sep-24 4:32 
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 
You might find this article interesting: Talking Clipboard[^]. Smile | :)

/ravi
My new year resolution: 2048 x 1536
Home | Articles | My .NET bits | Freeware
ravib(at)ravib(dot)com

AnswerRe: Also see... Pin
Teraten12-Nov-14 7:34
Teraten12-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.