Use Microsoft TTS voice in Asp.net

Source: Internet
Author: User

Implementation platform:
Microsoft Visual maxcompute 2005
Microsoft tts5.1 Speech Engine (Chinese)

Required items:
Click here to download dotnetspeech. dll (160 K) exported from sapi.51 SDK with tlbimp)
Microsoft tts5.1 Speech Engine (Chinese). MSI (1.55 m) and above are missing because of their size relationship, you can leave a mailbox address as needed. If you have installed the sapi.51 SDK, you can use this command to export dotnetspeech. dll.
Tlbimp SAPI. dll/out: dotnetspeech. dll)
Install Microsoft tts5.1 voice engine (Chinese ). msi, open "Control Panel", open "Voice" configuration item, select "Microsoft Simplified Chinese" in the "voice selection" combo box of "text-speech conversion ", in this way, Chinese characters can be read. To read English, select "Microsoft Sam ".

Use Microsoft Visual Studio 2005 to create a project, add references, and reference dotnetspeech. dll.
Namespace:
Using dotnetspeech;

Read Chinese characters in the text box:
Speechvoicespeakflags spflags = speechvoicespeakflags. svsflagsasync;
Spvoice voice = new spvoice ();
Voice. Speak (textbox1.text, spflags );

Save the Chinese pronunciation in the text box as a WAV file:
speechvoicespeakflags spflags = speechvoicespeakflags. svsflagsasync;
spvoice voice = new spvoice ();
savefiledialog dialog = new savefiledialog ();
dialog. filter = "all files (*. *) | *. * | WAV Files (*. wav) | *. wav ";
dialog. title = "Save WAV Files";
dialog. filterindex = 2;
dialog. restoredirectory = true;
If (dialog. showdialog () = dialogresult. OK)
{< br> speechstreamfilemode spfilemode = speechstreamfilemode. ssfmcreateforwrite;
spfilestream = new spfilestream ();
spfilestream. open (dialog. filename, spfilemode, false);
voice. audiooutputstream = spfilestream;
voice. speak (textbox1.text, spflags);
voice. waituntildone (1000);
the above two sentences must be written, otherwise the generated file has no sound
the smtimeout behind waituntildone is an int type
spfilestream. close ();

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.