Realizing the function of speech reading

Source: Internet
Author: User

Do not know if you have found that under the System.Speech.Synthesis namespace there is a SpeechSynthesizer class, it can specify the text content to read aloud, and, this class is also very simple to use, how simple to what extent? Try.

First of all, create a new project, whatever you build any project, you can test it anyway.

Then, add a reference to the System.speech assembly, which I don't need to teach you, you can not do it, as long as you use VS can not understand this.

Introduce the System.Speech.Synthesis namespace, and finally, watch, a few lines of code.

private void 

Button1_Click (object sender, EventArgs e)  
{  
    if (string). Isnullorwhitespace (Txttoread.text))  
    {return  
        ;  
    }  
    A new one speech on the  
    SpeechSynthesizer sp = new SpeechSynthesizer ();  
    Sp. Speakcompleted + = (s, arg) => button1. Enabled = true;  
      
    began to read  
    button1. Enabled = false;  
    Sp. Speakasync (Txttoread.text);  
}

Call the Speak method to start listening to the MM speech, I am calling here is an asynchronous version.

Run, enter some text, start reading, you will hear a mm of the sound of nature.

How's that feel?

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/csharp/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.