SpeechSynthesizer.SpeakSsmlAsync(String) SpeechSynthesizer.SpeakSsmlAsync(String) SpeechSynthesizer.SpeakSsmlAsync(String) SpeechSynthesizer.SpeakSsmlAsync(String) Method


以非同步方式讀出包含 SSML 標記的 StringAsynchronously speaks a String that contains SSML markup.

 System::Speech::Synthesis::Prompt ^ SpeakSsmlAsync(System::String ^ textToSpeak);
public System.Speech.Synthesis.Prompt SpeakSsmlAsync (string textToSpeak);
member this.SpeakSsmlAsync : string -> System.Speech.Synthesis.Prompt
Public Function SpeakSsmlAsync (textToSpeak As String) As Prompt


String String String String

要讀出的 SMML 標記。The SMML markup to speak.



using System;  
using System.Speech.Synthesis;  
namespace SampleSynthesis  
  class Program  
    static void Main(string[] args)  
      // Initialize a new instance of the SpeechSynthesizer.  
      SpeechSynthesizer synth = new SpeechSynthesizer();  
      // Configure the audio output.   
      // Build an SSML prompt in a string.  
      string str = "<speak version=\"1.0\"";  
      str += " xmlns=\"http://www.w3.org/2001/10/synthesis\"";  
      str += " xml:lang=\"en-US\">";  
      str += "<say-as type=\"date:mdy\"> 1/29/2009 </say-as>";  
      str += "</speak>";  
      // Speak the contents of the prompt asynchronously.  
      Console.WriteLine("Press any key to exit...");  


textToSpeak參數的內容必須speak包含元素, 而且必須符合語音合成標記語言 (SSML) 1.0 版The contents of the textToSpeak parameter must include a speak element and must conform to the Speech Synthesis Markup Language (SSML) Version 1.0. 如需詳細資訊, 請參閱語音合成標記語言參考For more information, see Speech Synthesis Markup Language Reference.

若要同步地說出包含 SSML 標記的字串, SpeakSsml請使用方法。To synchronously speak a string that contains SSML markup, use the SpeakSsml method. 您可以使用SpeakAsync , 對不包含 SSML 標記的字串起始非同步說。You can use SpeakAsync to initiate the asynchronous speaking of a string that does not contain SSML markup.

呼叫這個方法時, SpeechSynthesizer可以引發下列事件:During a call to this method, the SpeechSynthesizer can raise the following events:

  • StateChanged.StateChanged. 當合成器的朗讀狀態變更時引發。Raised when the speaking state of the synthesizer changes.

  • SpeakStarted.SpeakStarted. 當合成器開始產生語音時引發。Raised when the synthesizer begins generating speech.

  • PhonemeReached.PhonemeReached. 每次合成器到達以語言組成語音的字母或字母組合時, 就會引發。Raised each time the synthesizer reaches a letter or combination of letters that constitute a discreet sound of speech in a language.

  • SpeakProgress.SpeakProgress. 每次合成器以單字完成說話時引發。Raised each time the synthesizer completes speaking a word.

  • VisemeReached.VisemeReached. 每次說話的輸出需要變更, 或用來產生語音的臉部肌肉, 才會引發。Raised each time spoken output requires a change in the position of the mouth or the facial muscles used to produce speech.

  • BookmarkReached.BookmarkReached. 當合成器在提示中遇到書簽時引發。Raised when the synthesizer encounters a bookmark in a prompt.

  • VoiceChange.VoiceChange. 當合成器說話的語音變更時引發。Raised when the speaking voice for the synthesizer changes.

  • SpeakCompleted.SpeakCompleted. 當合成器完成工作處理SpeakSsmlAsync時引發。Raised when the synthesizer finishes processing a SpeakSsmlAsync operation.

如果您的Speak應用程式 dos 在說話時不需要執行工作, 您可以使用SpeakSsml或方法, 以同步方式產生語音。If your application dos not need to perform tasks while speaking, you can use the Speak or the SpeakSsml method to generate speech synchronously.