The ASP. NET client implements the voice (TTS) function through the speech SDK.

Source: Internet
Author: User
Tags sapi

Steps:
1) install the speech SDK
2) set after installation
3) WriteProgram

 

1. Install the speech SDK
In this example, the speech SDK 5.1 is used as an example. You need to install two files: speechsdk51 and speechsdk51langpack.
: Http://www.microsoft.com/downloads/en/details.aspx? Familyid = 5e86ec97-40a7-440f-b0ee-6583171b4530 & displaylang = en

2. Set after installation
After installation, go to Control Panel> voice. On the text-Voice Conversion tab, select Microsoft Simplified Chinese from voice selection ".

3. Write a program
Because the speech SDK cannot be used directly like winform in Asp.net, it can be implemented through ActiveX. The implementation method is below the aspx source code.Code:

Code

< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > </ Title >

< Script Type = "Text/JavaScript" >
// Create an SAPI spvoice object
VaR Voiceobj =   New Activexobject ( " SAPI. spvoice " );

// Read the text
Function Readvoice (){
VaR Voice = Document. getelementbyid ( " Txtvoice " ). Value;
Voiceobj. Speak (voice, 1 );
Return   False ;
}
</ Script >

</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
< Div >
<% -- Text to be read -- %>
< Input ID = "Txtvoice" Type = "Text"   />
< BR />
<% -- Read button -- %>
< Input ID = "Btnread" Type = "Button" Value = "Read" Onclick = "Return readvoice ()"   />
</ Div >
</ Form >
</ Body >
</ Html >

 

 

Run, enter Chinese characters in the text box, and click "read" to read the text.

 

Note:
1) if the error "Microsoft JScript runtime error: the Automation server cannot create objects" appears after running. Please go, in IE, "Tools"-> "Internet Options"-> "local Internet"-> "Custom Level"-> "Local intranet", "unmarked as a step-by-step script for security set ActiveX Control initialization and script execution to "enable ".
If you publish to another machine for running, you need to set this item in "Internet Options"> "Internet.
2) In the "Start Menu", "Microsoft Speech SDK 5.1" contains the "Microsoft Speech SDK 5.1 help" Help document. For more information, see this document.
3) In the installation directory of Microsoft Speech SDK 5.1, there is a "samples" folder, which provides some examples for reference.

Related Article

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.