SpeechSynthesizer.SpeakSsml(String) 方法

定義

以同步方式讀出包含 SSML 標記的 String

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

參數

textToSpeak
String

要讀出的 SSML 字串。

範例

下列範例會將日期 1/29/2009 轉譯為日期,以月、日、年順序呈現。

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 元素,且必須符合 語音合成標記語言 (SSML) 1.0 版。 如需詳細資訊,請參閱 語音合成標記語言參考

若要以非同步方式說出包含 SSML 標記的字串,請使用 SpeakSsmlAsync 方法。 您可以使用 Speak 來起始不包含 SSML 標記之字串的同步說話。

在呼叫此方法期間, SpeechSynthesizer 可以引發下列事件:

  • StateChanged. 合成器的說話狀態變更時引發。

  • SpeakStarted. 合成器開始產生語音時引發。

  • PhonemeReached. 每次合成器到達字母或字母組合時引發,以語言構成語音的離散音效。

  • SpeakProgress. 每次合成器完成說出單字時引發。

  • VisemeReached. 每次說出輸出都需要變更口音的位置,或用來產生語音的臉部神經。

  • BookmarkReached. 合成器在提示中遇到書簽時引發。

  • VoiceChange. 合成器的說話語音變更時引發。

SpeechSynthesizer處理 方法時 SpeakSsml ,不會引發 SpeakCompleted 事件。

適用於