Prompt 建構函式

定義

建立 Prompt 類別的新執行個體。

多載

Prompt(PromptBuilder)

PromptBuilder 物件建立 Prompt 類別的新執行個體。

Prompt(String)

建立 Prompt 類別的新執行個體並指定要說出的文字。

Prompt(String, SynthesisTextFormat)

建立 Prompt 類別的新執行個體,並指定需要講出的文字以及它的格式是純文字還是標記語言。

Prompt(PromptBuilder)

來源:
Prompt.cs
來源:
Prompt.cs
來源:
Prompt.cs

PromptBuilder 物件建立 Prompt 類別的新執行個體。

public:
 Prompt(System::Speech::Synthesis::PromptBuilder ^ promptBuilder);
public Prompt (System.Speech.Synthesis.PromptBuilder promptBuilder);
new System.Speech.Synthesis.Prompt : System.Speech.Synthesis.PromptBuilder -> System.Speech.Synthesis.Prompt
Public Sub New (promptBuilder As PromptBuilder)

參數

promptBuilder
PromptBuilder

要讀出的內容。

適用於

Prompt(String)

來源:
Prompt.cs
來源:
Prompt.cs
來源:
Prompt.cs

建立 Prompt 類別的新執行個體並指定要說出的文字。

public:
 Prompt(System::String ^ textToSpeak);
public Prompt (string textToSpeak);
new System.Speech.Synthesis.Prompt : string -> System.Speech.Synthesis.Prompt
Public Sub New (textToSpeak As String)

參數

textToSpeak
String

要說出的文字。

範例

下列範例會 Prompt 從字串建立 物件,並將 物件當做引數傳遞至 Speak 方法。

using System;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToDefaultAudioDevice();  

        // Create a prompt from a string.  
        Prompt color = new Prompt("What is your favorite color?");  

        // Speak the contents of the prompt synchronously.  
        synth.Speak(color);  
      }  

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

適用於

Prompt(String, SynthesisTextFormat)

來源:
Prompt.cs
來源:
Prompt.cs
來源:
Prompt.cs

建立 Prompt 類別的新執行個體,並指定需要講出的文字以及它的格式是純文字還是標記語言。

public:
 Prompt(System::String ^ textToSpeak, System::Speech::Synthesis::SynthesisTextFormat media);
public Prompt (string textToSpeak, System.Speech.Synthesis.SynthesisTextFormat media);
new System.Speech.Synthesis.Prompt : string * System.Speech.Synthesis.SynthesisTextFormat -> System.Speech.Synthesis.Prompt
Public Sub New (textToSpeak As String, media As SynthesisTextFormat)

參數

textToSpeak
String

要說出的文字。

media
SynthesisTextFormat

指定文字格式的值。

範例

下列範例會建置包含 SSML 標記的字串、從字串建立 Prompt 物件,以及說出提示。

using System;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToDefaultAudioDevice();  

        // Build an SSML prompt in a string.  
        string fileName = "<speak version=\"1.0\" ";  
        fileName += "xmlns=\"http://www.w3.org/2001/10/synthesis\" ";  
        fileName += "xml:lang=\"en-US\">";  
        fileName += "Say a name for the new file <mark name=\"fileName\" />.";  
        fileName += "</speak>";  

        // Create a Prompt object from the string.  
        Prompt ssmlFile = new Prompt(fileName, SynthesisTextFormat.Ssml);  

        // Speak the contents of the SSML prompt.  
        synth.Speak(ssmlFile);  
      }  

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

備註

參數的內容 textToSpeak 必須包含 speak 元素,而且必須符合 SSML) (1.0 版 (語音合成標記語言。 如需詳細資訊,請參閱 語音合成標記語言參考

適用於