SpeechSynthesizer.SpeakSsml(String) SpeechSynthesizer.SpeakSsml(String) SpeechSynthesizer.SpeakSsml(String) SpeechSynthesizer.SpeakSsml(String) Method

定義

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

public:
 void SpeakSsml(System::String ^ textToSpeak);
public void SpeakSsml (string textToSpeak);
member this.SpeakSsml : string -> unit
Public Sub SpeakSsml (textToSpeak As String)
參數
textToSpeak
String String String String

要讀出的 SSML 字串。 The SSML string to speak.

範例

下列範例會呈現日期的日期,每月、 日、 年的順序為 1/29/2009年。The following example renders the date 1/29/2009 as a date, in month, day, year order.

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.   
      synth.SetOutputToDefaultAudioDevice();  

      // 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 synchronously.
      synth.SpeakSsml(str);  

      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

備註

內容textToSpeak參數必須包含speak項目且必須符合1.0 版的語音合成標記語言 (SSML)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 標記的字串,使用SpeakSsmlAsync方法。To asynchronously speak a string that contains SSML markup, use the SpeakSsmlAsync method. 您可以使用Speak起始同步讀出不包含 SSML 標記的字串。You can use Speak to initiate the synchronous speaking of a string that does not contain SSML markup.

在這種方法,呼叫SpeechSynthesizer可能會引發下列事件:During a call to this method, the SpeechSynthesizer can raise the following events:

  • StateChangedStateChanged. 合成的讀出狀態變更時引發。Raised when the speaking state of the synthesizer changes.

  • SpeakStartedSpeakStarted. 合成器可讓您開始產生語音時引發。Raised when the synthesizer begins generating speech.

  • PhonemeReachedPhonemeReached. 每次引發合成達到字母或構成離散音效的語言中的語音字母的組合。Raised each time the synthesizer reaches a letter or combination of letters that constitute a discreet sound of speech in a language.

  • SpeakProgressSpeakProgress. 每次引發合成,完成讀出的文字。Raised each time the synthesizer completes speaking a word.

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

  • BookmarkReachedBookmarkReached. 合成器遇到的提示字元中的書籤時所引發。Raised when the synthesizer encounters a bookmark in a prompt.

  • VoiceChangeVoiceChange. 讀出的語音合成器的變更時引發。Raised when the speaking voice for the synthesizer changes.

SpeechSynthesizer不會引發SpeakCompleted事件處理時SpeakSsml方法。The SpeechSynthesizer does not raise the SpeakCompleted event while processing the SpeakSsml method.

適用於