Wednesday, June 25, 2014

Text To Voice Converter

Design Like this
Add References

After....
.Cs File

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

namespace TextToVoice_Convert
{
 
    public partial class Form1 : Form
    {

        SpeechSynthesizer ss=new SpeechSynthesizer();
        public Form1()
        {
        
           
        }

      
       
        private void btnRead_Click(object sender, EventArgs e)
        {
        
            ss.Rate = TraceBarSpeed.Value;
            ss.Volume = TrackBarVolume.Value;
            ss.SpeakAsync(Txtmsg.Text);
        }

        private void btnPause_Click(object sender, EventArgs e)
        {
          
            ss.Pause();
        }

        private void btnContinue_Click(object sender, EventArgs e)
        {
            ss.Resume();
           
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Text files |*.txt";
            ofd.ShowDialog();
            string fname;
            fname = ofd.FileName;
            var sr = new System.IO.StreamReader(fname);
            Txtmsg.Text = sr.ReadToEnd();
            sr.Close();
           
           
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnRecord_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "wave Files |*.wav";
            sfd.ShowDialog();
            String fname;
            fname = sfd.FileName;
            //SpeechSynthesizer ss = new SpeechSynthesizer();
            ss.Rate = TraceBarSpeed.Value;
            ss.Volume = TrackBarVolume.Value;
            ss.SetOutputToWaveFile(fname);
            ss.Speak(Txtmsg.Text);
            ss.SetOutputToDefaultAudioDevice();
            MessageBox.Show("Text Recorded as voice", "conform");

        }

       
    }
}