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.