Text to Speech in C#

This post explains how to create a text to speech application in c#. For this first you need to add "System.speech” references to your project.Create a new windows from application

Right Click on "References->Add References"


From the "Reference Manager" window click on Framework and then scroll down select "System.speech"

  

Source Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Speech.Synthesis;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TTSpeech
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SpeechSynthesizer syn = new SpeechSynthesizer();
            string str = textBox1.Text;
            syn.Speak(str);
            syn.Dispose();
        }
    }
}

Download Source Code



No comments :

Post a Comment