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.



BookmarkReached 事件傳回資料。Returns data from the BookmarkReached event.


表示從檔案建立的提示。Represents a prompt created from a file.


包含安裝在 Windows 中語音合成聲音的相關資訊。Contains information about a speech synthesis voice installed in Windows.


PhonemeReached 事件傳回資料。Returns data from the PhonemeReached event.


代表可以藉由 SpeechSynthesizer 轉譯之項目 (文字或音訊檔案) 的相關資訊。Represents information about what can be rendered, either text or an audio file, by the SpeechSynthesizer.


建立空的 Prompt 物件,並提供方法來加入內容、選取語音、控制語音屬性,以及控制口語發音。Creates an empty Prompt object and provides methods for adding content, selecting voices, controlling voice attributes, and controlling the pronunciation of spoken words.


表示 System.Speech.Synthesis 命名空間中 EventArgs 類別的基底類別。Represents the base class for EventArgs classes in the System.Speech.Synthesis namespace.


定義說話提示的樣式,其包含強調、速率及音量的設定。Defines a style for speaking prompts that consists of settings for emphasis, rate, and volume.


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


SpeakProgress 事件傳回資料。Returns data from the SpeakProgress event.


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


提供安裝的語音合成引擎功能的存取權。Provides access to the functionality of an installed speech synthesis engine.


StateChanged 事件傳回資料。Returns data from the StateChanged event.


VisemeReached 事件傳回資料。Returns data from the VisemeReached event.


VoiceChange 事件傳回資料。Returns data from the VoiceChange event.


表示已安裝的語音合成引擎。Represents an installed speech synthesis engine.



字組界限之間韻律分隔 (分隔) 間隔的列舉值。Enumerates values for intervals of prosodic separation (breaks) between word boundaries.


列舉提示中的強調等級值。Enumerates values for levels of emphasis in prompts.


列舉提示的讀出速率。Enumerates values for the speaking rate of prompts.


列舉提示中的音量 (聲音大小) 值。Enumerates values for volume levels (loudness) in prompts.


列舉適用於讀出如時間、日期和貨幣等項目的內容類型。Enumerates the content types for the speaking of elements such as times, dates, and currency.


列舉媒體檔案的類型。Enumerates the types of media files.


列舉可用來建構 Prompt 物件的文字格式類型。Enumerates the types of text formats that may be used to construct a Prompt object.


列舉合成器強調的等級。Enumerates levels of synthesizer emphasis.


SpeechSynthesizer 之狀態的列舉值。Enumerates values for the state of the SpeechSynthesizer.


定義合成語音的年齡的值。Defines the values for the age of a synthesized voice.


定義合成語音的性別的值。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. ASpeechSynthesizer執行個體初始化為預設的語音。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.

您可以使用引導文字的發音AppendTextWithHint或是AppendTextWithPronunciation方法,以及加入或移除的詞典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.

See also