Pages

Wednesday, January 28, 2015

C# Text to Voice Conversion-A simple App

Create a new project in visual studio. go to the references under the project folder in solution explorer.
right click on it and ADD a new reference. go to .NET tab and select the System.speech out of the list appearing and click OK. then use the speech.systhesis namespace, so that following code will give u a good output.


here is the code I used.
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.Synthesis;

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

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            SpeechSynthesizer ss = new SpeechSynthesizer();
            ss.Volume = 100; //volume must be between 0-100
            ss.Rate = 0; //rate must b between -10 to 10
            ss.SpeakAsync(textBox1.Text);
        }
    }
}

Don't forget to become a follower of SeethaGangula.!!!

No comments:

Post a Comment