Use TTS in. net

Source: Internet
Author: User
Tags sapi
Microsoft's SAPI (speech Application Programming Interface) provides powerful Text to Speech interfaces and supports automation. In this way Program To introduce the COM component:
Add a reference to speechlib and find SAPI. dll in the system disk's Program Files \ common files \ microsoft shared \ speech directory.
In Code The spvoiceclass class speak method can be called in a simple sentence: Ispeechvoice v = New Spvoiceclass ();
V. Speak (txtspeak, speechvoicespeakflags. svsfdefault );

You can also use spfilestream to create an audio stream. For example, the following program can "read" the text to the wav file: // Declare the spvoice object.
Ispeechvoice v = New Spvoiceclass ();
// Create a wave stream
Spfilestream s =   New Spfilestream ();
// Create a new. Wav file for writing.
S. Open ( "Out . Wav " , Speechstreamfilemode. ssfmcreateforwrite, False );
// Set the. Wav file stream as the output for the voice object
V. audiooutputstream = S;
// Call the Speak method now will send the output to the. Wav file.
V. Speak (txtspeak, speechvoicespeakflags. svsfdefault );
// Close the file
S. Close ();

This is just a few simple applications. Windows (my English version win2003) comes with SAPI does not support Chinese, Ms said version 5.1 SAPI can support Chinese, Japanese, and English languages, can be downloaded free of charge on the MS website. Continuing study ......

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.