.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Speech Recognition

Posted By:Syed Shakeer Hussain       Posted Date: August 14, 2010    Points: 25    Category: .Net Framework    URL: http://www.dotnetspark.com  

This Article explains you how to Convert Entered text to Speech Recognition(Voice) using C#
 

Before Starting to Write a code for converting a text into Speech Recognition(Voice),you have to add Referecne(DownLoad if not available)Interop.SpeechLib.

1)Add the NameSpace as Using SpeechLib

2)Create an object of SpVoice class 
   SpVoice voice = new SpVoice();

3)call the Speak() method by using Spvoice class object as follows and pass the parameters in the Speak()

    voice.Speak(String text,SpeechVoiceSpeakFlags Flags);

Lets Look the code:-

SpVoice voice = new SpVoice();

voice.Volume = 100;

voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);

Place the above code in the Button Click event.

Add one TextBox ,write some text in TextBox and click on the button to convert you TextBox text into Speech Recognition(VOICE) as follows

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using SpeechLib;

namespace VoiceTest
{

    public partial class Form1 : Form
    {

        public Form1()
        {

            InitializeComponent();

        }

        private void btnSpeak_Click(object sender,EventArgse)
        {

            if (textBox1.Text != "")
            {

                SpVoice voice = new SpVoice();

                voice.Volume = 100;

     voice.Speak(textBox1.Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);


            }

            else
            {

       MessageBox.Show("Please enter text for speech", "Text to Speech", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

    }

}


Note:-If you didnt find the Interop.SpeechLib dll in your project,you can download from below attachments and add it.

Hope you enjoyed it !

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend