System.Speech.Synthesis Namespace

N:System.Speech.Synthesis 命名空间包含初始化和配置语音合成引擎、创建提示、生成语音、响应事件和修改语音属性的类。 The N:System.Speech.Synthesis namespace contains classes for initializing and configuring a speech synthesis engine, for creating prompts, for generating speech, for responding to events, and for modifying voice characteristics.

BookmarkReachedEventArgs

BookmarkReached 事件返回数据。Returns data from the BookmarkReached event.

FilePrompt

表示从文件创建的提示。Represents a prompt created from a file.

InstalledVoice

包含有关 Windows 中安装的语音合成的声音的信息。Contains information about a speech synthesis voice installed in Windows.

PhonemeReachedEventArgs

PhonemeReached 事件返回数据。Returns data from the PhonemeReached event.

Prompt

表示 SpeechSynthesizer 可以呈现的内容(文本或音频文件)的相关信息。Represents information about what can be rendered, either text or an audio file, by the SpeechSynthesizer.

PromptBuilder

创建空的 Prompt 对象,并为添加内容、选择语音、控件语音属性和控件朗读单词的发音提供方法。Creates an empty Prompt object and provides methods for adding content, selecting voices, controlling voice attributes, and controlling the pronunciation of spoken words.

PromptEventArgs

表示在 System.Speech.Synthesis 命名空间中 EventArgs 类的基类。Represents the base class for EventArgs classes in the System.Speech.Synthesis namespace.

PromptStyle

定义由重点、速率和音量设置组成的语音提示的样式。Defines a style for speaking prompts that consists of settings for emphasis, rate, and volume.

SpeakCompletedEventArgs

SpeakCompleted 事件返回通知。Returns notification from the SpeakCompleted event.

SpeakProgressEventArgs

SpeakProgress 事件返回数据。Returns data from the SpeakProgress event.

SpeakStartedEventArgs

SpeakStarted 事件返回通知。Returns notification from the SpeakStarted event.

SpeechSynthesizer

提供对已安装的语音合成引擎的功能的访问。Provides access to the functionality of an installed speech synthesis engine.

StateChangedEventArgs

StateChanged 事件返回数据。Returns data from the StateChanged event.

VisemeReachedEventArgs

VisemeReached 事件返回数据。Returns data from the VisemeReached event.

VoiceChangeEventArgs

VoiceChange 事件返回数据。Returns data from the VoiceChange event.

VoiceInfo

表示一个安装的语音合成引擎。Represents an installed speech synthesis engine.

枚举

PromptBreak

枚举字边界之间韵律分离(中断)间隔的值。Enumerates values for intervals of prosodic separation (breaks) between word boundaries.

PromptEmphasis

枚举在提示的焦点的级别值。Enumerates values for levels of emphasis in prompts.

PromptRate

枚举提示的语速的值。Enumerates values for the speaking rate of prompts.

PromptVolume

枚举提示的卷级别的值。Enumerates values for volume levels (loudness) in prompts.

SayAs

枚举元素朗读的内容类型如时间、日期和货币。Enumerates the content types for the speaking of elements such as times, dates, and currency.

SynthesisMediaType

枚举媒体文件的类型。Enumerates the types of media files.

SynthesisTextFormat

枚举可用于构造 Prompt 对象的文本格式的类型。Enumerates the types of text formats that may be used to construct a Prompt object.

SynthesizerEmphasis

枚举合成器焦点的级别。Enumerates levels of synthesizer emphasis.

SynthesizerState

枚举 SpeechSynthesizer 状态的值。Enumerates values for the state of the SpeechSynthesizer.

VoiceAge

定义合成语音期限的值。Defines the values for the age of a synthesized voice.

VoiceGender

定义合成语音性别的值。Defines the values for the gender of a synthesized voice.

注解

初始化和配置Initialize and Configure

SpeechSynthesizer类提供了对安装在主计算机的语音合成引擎功能的访问。The SpeechSynthesizer class provides access to the functionality of a speech synthesis engine that is installed on the host computer. 安装语音合成引擎由语音,例如 Microsoft Anna。Installed speech synthesis engines are represented by a voice, for example Microsoft Anna. 一个SpeechSynthesizer实例初始化为默认语音。A SpeechSynthesizer instance initializes to the default voice. 若要配置SpeechSynthesizer实例,以使用其他已安装语音,调用之一SelectVoiceSelectVoiceByHints方法。To configure a SpeechSynthesizer instance to use one of the other installed voices, call the SelectVoice or SelectVoiceByHints methods. 若要获取有关哪些安装语音的信息,请使用GetInstalledVoices方法。To get information about which voices are installed, use the GetInstalledVoices method.

可以将路由的输出SpeechSynthesizer到流、 文件、 默认音频设备,或使用中的方法之一为 null 设备SpeechSynthesizer名称开头的类"SetOutputTo"。You can route the output of the SpeechSynthesizer to a stream, a file, the default audio device, or to a null device by using one of the methods in the SpeechSynthesizer class whose name begins with "SetOutputTo".

创建提示Create Prompts

使用其中一个的方法PromptBuilder名称开头的类"Append"构建用于从文本,语音合成标记语言 (SSML),提示的内容包含文本或 SSML 标记或预先录制的音频文件的文件。Use one the methods of the PromptBuilder class whose name begins with "Append" to build content for prompts from text, Speech Synthesis Markup Language (SSML), files containing text or SSML markup, or prerecorded audio files.

请参阅构造复杂提示系统语音.NET Framework 编程指南有关详细信息和示例。See Constructing a Complex Prompt in the System Speech Programming Guide for .NET Framework for more information and examples.

生成语音Generate Speech

若要从一个字符串,或从生成语音PromptPromptBuilder对象,请使用SpeakSpeakAsync方法。To generate speech from a string or from a Prompt or PromptBuilder object, use the Speak or the SpeakAsync methods. 若要从 SSML 标记生成语音,请使用SpeakSsmlSpeakSsmlAsync方法。To generate speech from SSML markup, use the SpeakSsml or the SpeakSsmlAsync methods. 请参阅语音合成标记语言参考有关 SSML 标记的指南。See Speech Synthesis Markup Language Reference for a guide to SSML markup.

可以通过使用引导的单词的发音AppendTextWithHintAppendTextWithPronunciation方法,并通过添加或删除的词典SpeechSynthesizer实例使用AddLexiconRemoveLexicon方法。You can guide the pronunciation of words by using the AppendTextWithHint or AppendTextWithPronunciation methods, and by adding or removing lexicons for a SpeechSynthesizer instance using the AddLexicon and RemoveLexicon methods.

对事件做出响应Respond to Events

SpeechSynthesizer类包括通知语音应用程序的事件,SpeechSynthesizer遇到在提示符中,特定功能,如报告SpeakProgressEventArgsBookmarkReachedEventArgsPhonemeReachedEventArgs,并VisemeReachedEventArgs类。The SpeechSynthesizer class includes events that inform a speech application that the SpeechSynthesizer encountered a specific feature in a prompt, as reported by the SpeakProgressEventArgs, BookmarkReachedEventArgs, PhonemeReachedEventArgs, and VisemeReachedEventArgs classes.

若要获取的开头和结尾的提示符下通过谈到有关的信息SpeechSynthesizer,使用SpeakStartedEventArgsSpeakCompletedEventArgs类。To get information about the beginning and end of the speaking of a prompt by the SpeechSynthesizer, use the SpeakStartedEventArgs and SpeakCompletedEventArgs classes.

请参阅使用语音合成事件系统语音.NET Framework 编程指南有关详细信息和示例。See Using Speech Synthesis Events in the System Speech Programming Guide for .NET Framework for more information and examples.

修改语音属性Modify Voice Characteristics

PromptStyle类和StartStyleAppendText方法可让你修改的特征SpeechSynthesizer语音使用EmphasisRate,和Volume参数。The PromptStyle class and StartStyle and AppendText methods let you modify characteristics of a SpeechSynthesizer voice using Emphasis, Rate, and Volume parameters. 若要修改例如区域性、 年龄和性别的语音的特征,请使用之一StartVoice的方法PromptBuilder类或SelectVoiceByHints方法的SpeechSynthesizer类。To modify characteristics of a voice such as culture, age, and gender, use one of the StartVoice methods of the PromptBuilder class or the SelectVoiceByHints methods of the SpeechSynthesizer class.

请参阅特性控制语音系统语音.NET Framework 编程指南有关详细信息。See Controlling Voice Attributes in the System Speech Programming Guide for .NET Framework for more information.