+92 332 4229 857 99ProjectIdeas@Gmail.com

Text To Speech Converter (C#.net)




The following program shows you , text to speech converter in two ways.. old way using SpeechLib; and in new way
using System.Speech.Synthesis; you can also load whole file to read.









public void btnSpeak_Click(System.Object sender, System.EventArgs e)
{
    textToSpeechNew();
}


public void textToSpeechOld() // Old way using using SpeechLib Library
{
    SpVoice speech = new SpVoice();
    speech.Speak(RichTextBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
    speech.Rate = 5;
    speech.Volume = 50;
}


public void textToSpeechNew() // New way using System.Speech Library
{
    SpeechSynthesizer speech = new SpeechSynthesizer();
    speech.Speak(RichTextBox1.Text);
    speech.Rate = 5;
    speech.Volume = 50;
}


public void btnLoadFile_Click(object sender, EventArgs e)
{
   if (openFileDialog1.ShowDialog() == DialogResult.OK)
   {
        TextReader tr = File.OpenText(openFileDialog1.FileName);
        RichTextBox1.Text = tr.ReadToEnd();
        textToSpeechNew();
   }
               
}








0 comments: