Thursday, May 19, 2011

Text to Speech Using C#

To convert text to speech just add a reference in your project to System.Speech(.Net) and to Microsoft speech object library(com).

Then use the following code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech;
using System.Speech.Synthesis;

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

private void button1_Click(object sender, EventArgs e)
{
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.Rate = -10;
synth.Speak(textBox1.Text);
synth.Dispose();
}
}
}

1 comment: