Microsoft Speech Platform

Source: Internet
Author: User

In the previous blog, Microsoft's voice platform is generally referred to as TTS. It is implemented using the class SpeechSynthesizer in the Xiangwei SDK.

First, let's look at the simplest method:

SpeechSynthesizer speech = newSpeechSynthesizer ();

Speech. setoutputtodefaauaudiodevice ();

Speech. Volume = 50;

Speech. Rate = 0;

Speech. Speak ("this is the audio content! ");

The setoutputtodefaauaudiodevice method is a required method, indicating that the voice is played on the current default playback device. There are several other methods, namely, output to a stream or file, and Volume indicates the Volume during playback, the value ranges from 0 to 100, the Rate is the speed, and the value ranges from-10 to 10. The Speak method of the last row is to start reading the content. It seems that it is not very difficult, but now there is a problem: when reading aloud, the UI of the program is stuck until the reading is complete, this user experience will certainly not work. What should I do? One method is custom multithreading, and the other is to call the asynchronous Speak method of SpeechSynthesizer, that is, SpeakAsync.

What should I do if I want to make some changes when reading a piece of text? It can be implemented using PromptBuilder. This is a collection class. It stores multiple text information and adds corresponding expression attributes to the text information to achieve different expressions of each sentence, for example, the following code:

Speech = newSpeechSynthesizer ();

Speech. setoutputtodefaauaudiodevice ();

Speech. Volume = 100;

Speech. Rate = 0;

PromptBuilder pb = newPromptBuilder ();

Pb. AppendText ("First sentence,", PromptRate. Fast );

Pb. AppendText ("Second sentence,", PromptRate. Slow );

Speech. SpeakAsync (pb );

When reading two sentences, the speed of speech is different.

For more information about the Microsoft voice platform, see http://msdn.microsoft.com/en-us/library/dd266409 (v = office.14). aspx

 

This article is from "Gui Su Wei" blog, please be sure to keep this source http://axzxs.blog.51cto.com/730810/1246583

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.