Sunteți pe pagina 1din 2

Windows.Media.

SpeechSynthesis namespace - Windows app development

1 of 2

http://msdn.microsoft.com/library/windows/apps/windows.media.speechs...

Windows.Media.SpeechSynthesis namespace
Provides support for initializing and configuring a speech synthesis engine (voice) to convert a text string to an audio stream, also known as text-tospeech (TTS). Voice characteristics, pronunciation, volume, pitch, rate or speed, emphasis, and so on are customized through Speech Synthesis
Markup Language (SSML).

Members
The Windows.Media.SpeechSynthesis namespace has these types of members:
Classes
Enumerations
Classes
The Windows.Media.SpeechSynthesis namespace has these classes.
Class

Description

SpeechSynthesisStream

Supports reading and writing audio data generated by the speech synthesis engine (voice) to/from a random access
stream.

SpeechSynthesizer

Provides access to the functionality of an installed speech synthesis engine (voice).

VoiceInformation

Provides info about an installed speech synthesis engine (voice).

Enumerations
The Windows.Media.SpeechSynthesis namespace has these enumerations.
Enumeration

Description

VoiceGender

Specifies the gender settings for an installed speech synthesis engine (voice).

Generating speech output from plain text


The following example demonstrates how a Windows Store app uses a SpeechSynthesizer object to create an audio stream and output speech
based on a plain text string.
C#

// The media object for controlling and playing audio.


MediaElement mediaElement = this.media;
// The object for controlling the speech synthesis engine (voice).
var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
// Generate the audio stream from plain text.
SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Hello World");
// Send the stream to the media object.
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();

1/14/2015 7:09 PM

Windows.Media.SpeechSynthesis namespace - Windows app development

2 of 2

http://msdn.microsoft.com/library/windows/apps/windows.media.speechs...

Generating speech output from SSML


The following example demonstrates how a Windows Store app uses a SpeechSynthesizer object to create an audio stream and output speech
based on an SSML text string.
C#

// The string to speak with SSML customizations.


string Ssml =
@"<speak version='1.0' " +
"xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'>" +
"Hello <prosody contour='(0%,+80Hz) (10%,+80%) (40%,+80Hz)'>World</prosody> " +
"<break time='500ms' />" +
"Goodbye <prosody rate='slow' contour='(0%,+20Hz) (10%,+30%) (40%,+10Hz)'>World</prosody>" +
"</speak>";
// The media object for controlling and playing audio.
MediaElement mediaElement = this.media;
// The object for controlling the speech synthesis engine (voice).
var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
// Generate the audio stream from plain text.
SpeechSynthesisStream stream = await synth.synthesizeSsmlToStreamAsync(Ssml);
// Send the stream to the media object.
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();

Requirements
Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Media.SpeechSynthesis
Windows::Media::SpeechSynthesis [C++]

Metadata

Windows.winmd

See also
Samples
Speech synthesis sample

2015 Microsoft

1/14/2015 7:09 PM

S-ar putea să vă placă și